Open Gozala opened 5 years ago
Yeah, I don't have fetch supporting different resource types yet. Does it work with fetch in the browser?
Yeah, I don't have fetch supporting different resource types yet. Does it work with fetch in the browser?
I think it does if your app is loaded from file:// url. I could be wrong though.
Truth is I did not necessarily cared about file urls per say, mostly it was to read some file via module relative path. On a web usually just resolve url and fetch it. So maybe modules should not have file://
url but something like resource:///
or app:///
where root instead ? That would address this use case without exposing full read access to filesystem.
I'd rather not stray too far from stuff that would work in the web. đŸ˜…
I just tried and fetch doesn't support file://
URLs. I think #15 with the file API would be a safer bet for now.
I just tried and fetch doesn't support
file://
URLs. I think #15 with the file API would be a safer bet for now.
That is why I suggested to maybe use different schema than "file://" because on the web you usually resolve URL relative to something and then fetch it.
And in fact fetch on file URLs do work as long as the files you're trying to fetch are under the same path as document doing the fetch.
Weird, I tied doing fetch(window.location.href)
in Chrome which resulted in it complaining about CORS not being set.
I was thinking of integrating the JSDOM resource loader and tying it together with the protocol loading stuff used for loading modules.
hmm it could be that chrome deals with that differently, I did try on Firefox
Either way. Primary point I was trying to make is that it's not uncommon to fetch stuff with a relative URL. The fact that it happens to be file://
URL in this instance isn't a secondary IMO.
Yeah, I agree. My biggest worry is how to handle all the different semantics of fetch for every type of protocol. Like, the obvious fetch(url)
case doesn't require much thinking, but there's various headers and partial downloads which might get difficult. I'm sure I could work off of whatever JSDOM did, though.
I get following error when trying to read contents of the file that is located next to the module:
I believe that is due to the fact that fetch does not seem to support
file://
urls