From 166eb782f9d3a7737d23299cc78eed79ba59185b Mon Sep 17 00:00:00 2001 From: Bradley Farias Date: Fri, 25 Feb 2022 10:05:55 -0600 Subject: esm: fix base URL for network imports PR-URL: https://github.com/nodejs/node/pull/42131 Reviewed-By: Geoffrey Booth Reviewed-By: Guy Bedford Reviewed-By: Benjamin Gruenbaum --- test/es-module/test-http-imports.mjs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') 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, -- cgit v1.2.1