download icon indicating copy to clipboard operation
download copied to clipboard

Data URI decoder is not selected properly

Open ghost opened this issue 8 years ago • 0 comments

		function dataUrlToBlob(strUrl) {
			var parts= strUrl.split(/[:;,]/),
			type= parts[1],
			decoder= parts[2] == "base64" ? atob : decodeURIComponent,
			...
		}

https://github.com/rndme/download/blob/master/download.js#L90

This one fails, it is generated with google first hit from text:

data:text/plain;charset=utf-8;base64,w4FydsOtenTFsXLFkXTDvGvDtnJmw7p0w7Nnw6lwLg==

The problem that the charset is given, so the second part is the charset rather than the encoding. You should parse the heading part of the URI instead of making presumptions on its structure.

ghost avatar Mar 13 '17 17:03 ghost