| 16:09 | <devsnek> | is there any web api to parse a data url correctly |
| 16:09 | <devsnek> | e.g. `new URL('data:text/javascript,a ? b : c')` would cut out the `? b : c` from pathname |
| 16:55 | <grumble> | devsnek: what about XHR or fetch on the data url? |
| 17:01 | <devsnek> | grumble: could work I guess, I'd rather something synchronous though |
| 17:38 | <Domenic> | devsnek: no there is not. Use https://github.com/jsdom/data-urls or probably some variant of it that doesn't have a whatwg-url dependency (and uses native URL instead). |
| 17:38 | <Domenic> | cf. https://github.com/jsdom/data-urls/issues/7 by TimothyGu |
| 17:38 | <devsnek> | aw i was hoping i wouldn't need to pull in deps or something to add data uris to node's esm resolver |
| 17:39 | <devsnek> | thanks though |
| 17:40 | <Domenic> | It's surprisingly complicated |
| 17:40 | <Domenic> | You need two dependent parsers: forgiving-base64, and MIME type |
| 17:40 | <Domenic> | Not to mention URL, I suppose |
| 17:40 | <Domenic> | Once you have those the actual code is smallish. https://github.com/jsdom/data-urls/blob/master/lib/parser.js |
| 18:50 | <devsnek> | Domenic: do you know if node's buffer base64 is "forgiving"? I can't find anything informative online |
| 18:51 | <Domenic> | devsnek: no idea. Check against https://infra.spec.whatwg.org/#forgiving-base64 or the tests in web platform tests. |