parse-data-url icon indicating copy to clipboard operation
parse-data-url copied to clipboard

Browser support

Open strarsis opened this issue 5 years ago • 5 comments

Would it be possible to add UMD or whatever thing is needed for just using it in browser? This would be really helpful for protoyping.

strarsis avatar Apr 20 '20 12:04 strarsis

@strarsis Please test this version: https://github.com/killmenot/parse-data-url/tree/browser-support and let me know how it works

killmenot avatar Apr 20 '20 21:04 killmenot

@strarsis does it work as planned? Have you had a chance to test it?

killmenot avatar May 04 '20 22:05 killmenot

Thanks for the follow up. I tried it standalone in a codepen, but the function cannot be found, see this pen: https://codepen.io/strarsis/pen/yLYpJRM

strarsis avatar May 04 '20 22:05 strarsis

@strarsis parseDataUrl requires valid-data-url to work correctly. See here. If it's not defined it throws an error

However, even if I include valid-data-url in your pen still doesn't work as expected: https://codepen.io/killmenot/pen/eYprmbG

There are 2 problems:

  1. data section must be URL encoded
  2. parameters in media type should be correct per https://tools.ietf.org/html/rfc2397#section-3 . So instead of image/svg+xml;utf8, it should be image/svg+xml;charset=utf8 or image/svg+xml`

See another pen: https://codepen.io/killmenot/pen/MWarXYz

killmenot avatar May 09 '20 12:05 killmenot

@killmenot: In the console, I can view an Object now. The data attribute contains the data, but it is still encoded. Can this library also decode the data, depending on what encoding/escaping was used.

strarsis avatar May 09 '20 13:05 strarsis