Bug 205294 - import.meta.url: baseURL for a module script should be response URL, not request URL
Summary: import.meta.url: baseURL for a module script should be response URL, not requ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari 13
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
Keywords: InRadar
Depends on:
Reported: 2019-12-16 12:30 PST by Justin Fagnani
Modified: 2019-12-17 06:43 PST (History)
5 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Justin Fagnani 2019-12-16 12:30:09 PST
According to: https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts:creating-a-module-script-2

The base URL for a module script should be the response URL, post any redirects. Currently Webkit is using the request URL.

This causes significant problems (and incompatibility with Firefox and Chrome) when there are redirects in the response for a module.

Imagine you are using something like `new URL('./foo.jpg', import.meta.url).href` to get the URL for an image relative to the main module of an NPM package. A CDN like unpkg.com will perform a redirect from `unpkg.com/foo` to the main module, ie: `unpkg.com/foo/index.js`. This causes there to be a difference in the image's URL depending on whether `import.meta.url` uses response or request URL. Response URL will give `unpkg.com/foo/foo.jpg` while request URL will give `unpkg.com/foo.jpg`.
Comment 1 Radar WebKit Bug Importer 2019-12-16 13:24:53 PST