summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBradley Farias <bradley.meck@gmail.com>2022-02-25 10:05:55 -0600
committerDanielle Adams <adamzdanielle@gmail.com>2022-04-23 22:47:23 -0400
commit166eb782f9d3a7737d23299cc78eed79ba59185b (patch)
treef676b9210da82d32e59a1d8b11c2445c8da6ea45 /test
parentb68db72746fe9c997d29de6675115b67d481c694 (diff)
downloadnode-new-166eb782f9d3a7737d23299cc78eed79ba59185b.tar.gz
esm: fix base URL for network imports
PR-URL: https://github.com/nodejs/node/pull/42131 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/es-module/test-http-imports.mjs15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/es-module/test-http-imports.mjs b/test/es-module/test-http-imports.mjs
index 139c72a4e2..a1a208689f 100644
--- a/test/es-module/test-http-imports.mjs
+++ b/test/es-module/test-http-imports.mjs
@@ -111,6 +111,21 @@ for (const { protocol, createServer } of [
assert.strict.notEqual(redirectedNS.default, ns.default);
assert.strict.equal(redirectedNS.url, url.href);
+ // Redirects have the same import.meta.url but different cache
+ // entry on Web
+ const relativeAfterRedirect = new URL(url.href + 'foo/index.js');
+ const redirected = new URL(url.href + 'bar/index.js');
+ redirected.searchParams.set('body', 'export let relativeDepURL = (await import("./baz.js")).url');
+ relativeAfterRedirect.searchParams.set('redirect', JSON.stringify({
+ status: 302,
+ location: redirected.href
+ }));
+ const relativeAfterRedirectedNS = await import(relativeAfterRedirect.href);
+ assert.strict.equal(
+ relativeAfterRedirectedNS.relativeDepURL,
+ url.href + 'bar/baz.js'
+ );
+
const crossProtocolRedirect = new URL(url.href);
crossProtocolRedirect.searchParams.set('redirect', JSON.stringify({
status: 302,