New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URL vs URL string #462
Comments
Per spec, the RequestInfo is a Request or string URL. The "Input" is a string URL or Request. Therefore, in both cases, the spec says that URLs should be passed as strings, not URL instances. |
This is how I understand the specification as well. It's interesting, though, that Chrome, Edge, Firefox, and Safari Technology Preview all accept a URL object as the input parameter. Intuitively, we expect passing a URL object to work, so maybe we're misreading the spec? |
I don't think we're misreading the spec. In case of
|
Thanks for clarifying. FWIW I think what is confusing is the spec actually shows a URL being used in an example not to mention as @dgraham mentioned, most browsers supporting it now too. var url = new URL("https://geo.example.org/api"),
params = {lat:35.696233, long:139.570431}
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
fetch(url).then(/* … */) |
@joeshub Ah, nice find. I agree that it would be intuitive to support URLs. If you have the time, you could try adding the tests that verify that we accept URL objects properly. Meanwhile, I'm going to open an issue in the spec repo asking for details. |
Here's the official reply:
This is interesting and probably not what we do in the polyfill. We will have to change our behavior for spec compliance. |
The |
I could be wrong, but it appears the Fetch specification and most native implementations accept a URL object as the first parameter to fetch() while it appears most of the examples here require a URL string, and passing a URL object breaks non-native implementations, for example Safari.
Is this polyfill built to support an URL object or URL string?
Thank you
The text was updated successfully, but these errors were encountered: