I have a method that generates a data URI from a byte array. In the event the input byte array is empty, what is the appropriate thing for the method to do? Here are the options I see:return data:,return an empty Stringthrow an ExceptionBy my read, RFC 2397 doesn't explicitly address the notion of empty data.
What is the appropriate Data URI to use for 0-byte content?
specifications;null;uri
RFC 2397 explicitly allows empty data. Let's look at the relevant parts of the grammar:dataurl    := data: [ mediatype ] [ ;base64 ] , data...data       := *urlcharThe * quantifier means zero or more repetitions, the square brackets contain optional parts. Therefore the shortest data-URL is indeed data:,. In your context, you'll probably use data:text/plain;base64, or something like that instead.