-
Notifications
You must be signed in to change notification settings - Fork 2.9k
import.meta.url needs its fragment censored #3622
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
Comments
If this only is the response URL I would request exposing a way to get the full URL. What is the reason to not include the fragment? It seems weird that we execute multiple times but are unable to determine the fragment and therefore cache entry to bust that the execution is tied to. |
It's not really a choice between exposing the fragment and not. It's between exposing the response URL (never includes a fragment) and exposing the request URL (may include a fragment). The response URL is generally the useful one, since e.g. if you do fetches relative to the request URL, you will probably get the wrong result. For example, consider <!-- https://example.com/index.html -->
<script type="module" src="a.mjs"> Inside the redirected-to fetch(new URL("foo.json", import.meta.url)); Currently, this fetches |
@domenic my understanding was that |
No, it's intended to give you a URL relative to which you can find other resources. It's not meant to serve as a kind of identifier into the (invisible-to-developers) module map. |
Interesting, not what I would hope for. Might need to come back to this since I think it would be a big enough thing for me to think about requesting removing from Node. Need to think. |
I think per whatwg/fetch#505 we want to expose the fragment here (and basically stop hiding it everywhere). |
Oh, wow, I forgot about that thread. Browsers even magically copy the fragment across redirects!? Amazing. |
I take it this can be closed then? |
I think we probably still want to make sure it's tested. |
Chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=841831 Other browsers don't seem to have implemented import.meta yet :( |
…s, a=testonly Automatic update from web-platform-testsTest import.meta.url preserving fragments Closes whatwg/html#3622. -- wpt-commits: 38a9456c9ff3d2e666cf404415e472e11fffd43d wpt-pr: 10717
…s, a=testonly Automatic update from web-platform-testsTest import.meta.url preserving fragments Closes whatwg/html#3622. -- wpt-commits: 38a9456c9ff3d2e666cf404415e472e11fffd43d wpt-pr: 10717
…s, a=testonly Automatic update from web-platform-testsTest import.meta.url preserving fragments Closes whatwg/html#3622. -- wpt-commits: 38a9456c9ff3d2e666cf404415e472e11fffd43d wpt-pr: 10717 UltraBlame original commit: f424009146ecf744fea3f99db4943d7ae2837d74
…s, a=testonly Automatic update from web-platform-testsTest import.meta.url preserving fragments Closes whatwg/html#3622. -- wpt-commits: 38a9456c9ff3d2e666cf404415e472e11fffd43d wpt-pr: 10717 UltraBlame original commit: f424009146ecf744fea3f99db4943d7ae2837d74
…s, a=testonly Automatic update from web-platform-testsTest import.meta.url preserving fragments Closes whatwg/html#3622. -- wpt-commits: 38a9456c9ff3d2e666cf404415e472e11fffd43d wpt-pr: 10717 UltraBlame original commit: f424009146ecf744fea3f99db4943d7ae2837d74
Uh oh!
There was an error while loading. Please reload this page.
Edit: to those coming to this thread fresh, the OP may be confusing. The conclusion of this thread was that the spec was good as-is, but we needed to add tests because browsers were not consistent. The tests were added in web-platform-tests/wpt#10717. Keep reading for the gory details.
Because it exposes a response URL for the script, the fragment should be censored, per Fetch's definition of response URL:
However, it appears that specs need to carefully censor this themselves, e.g. like Fetch does in the
response.url
getter.HTML was not careful about this, and @bmeck has reported that this caused interop problems where Safari followed the HTML spec verbatim (and so included the fragment) whereas Chrome used their usual response-URL infrastructure (and thus didn't have a fragment around).
Almost certainly the right thing to do here is censor the fragment and add a WPT ensuring that it stays that way.
/cc @annevk @whatwg/modules
The text was updated successfully, but these errors were encountered: