diff --git a/core/deno_cache.ts b/core/deno_cache.ts index 6a79a136..9a1f695a 100644 --- a/core/deno_cache.ts +++ b/core/deno_cache.ts @@ -125,7 +125,7 @@ export class CacheModule implements DenoCacheModule { targetOriginDir = path.join( getDenoDepsDir(), url.protocol.replace(/:$/, ""), // https: -> https - url.hostname + `${url.hostname}${url.port ? `_PORT${url.port}` : ""}` ); } // invalid diff --git a/core/module_resolver.test.ts b/core/module_resolver.test.ts index ce68e039..0b3653f4 100644 --- a/core/module_resolver.test.ts +++ b/core/module_resolver.test.ts @@ -28,6 +28,8 @@ test("core / module_resolver: resolve module from Deno cache", () => { "./sub/mod.ts", "/esm/mod.ts", "https://example.com/esm/mod.ts", + "https://example.com:443/esm/mod.ts", + "http://localhost:3000/mod.ts", "./module_not_exist.ts", "https://module.not.exist.com/mod.ts", ]) @@ -56,6 +58,25 @@ test("core / module_resolver: resolve module from Deno cache", () => { "8afd52da760dab7f2deda4b7453197f50421f310372c5da3f3847ffd062fa1cf" ), }, + { + extension: ".ts", + origin: "https://example.com:443/esm/mod.ts", + filepath: path.join( + path.dirname(cacheFilepath), + "8afd52da760dab7f2deda4b7453197f50421f310372c5da3f3847ffd062fa1cf" + ), + }, + { + extension: ".ts", + origin: "http://localhost:3000/mod.ts", + filepath: path.join( + denoDir, + "deps", + "http", + "localhost_PORT3000", + "51a61f14fdad404fd2c9187363be7846d6d3b84a2b8697b9bd50c60d4509ab60" + ), + }, undefined, undefined, ] as ResolvedModule[]); diff --git a/core/module_resolver.ts b/core/module_resolver.ts index ce40ca9a..d9cd6892 100644 --- a/core/module_resolver.ts +++ b/core/module_resolver.ts @@ -75,7 +75,7 @@ export class ModuleResolver implements ModuleResolverInterface { const originDir = path.join( getDenoDepsDir(), url.protocol.replace(/:$/, ""), // https: -> https - url.hostname + `${url.hostname}${url.port ? `_PORT${url.port}` : ""}` // hostname.xyz:3000 -> hostname.xyz_PORT3000 ); const hash = hashURL(url); diff --git a/core/testdata/deno_dir_manifest/deps/http/localhost_PORT3000/51a61f14fdad404fd2c9187363be7846d6d3b84a2b8697b9bd50c60d4509ab60 b/core/testdata/deno_dir_manifest/deps/http/localhost_PORT3000/51a61f14fdad404fd2c9187363be7846d6d3b84a2b8697b9bd50c60d4509ab60 new file mode 100644 index 00000000..e69de29b diff --git a/core/testdata/deno_dir_manifest/deps/http/localhost_PORT3000/51a61f14fdad404fd2c9187363be7846d6d3b84a2b8697b9bd50c60d4509ab60.metadata.json b/core/testdata/deno_dir_manifest/deps/http/localhost_PORT3000/51a61f14fdad404fd2c9187363be7846d6d3b84a2b8697b9bd50c60d4509ab60.metadata.json new file mode 100644 index 00000000..5f3b30f5 --- /dev/null +++ b/core/testdata/deno_dir_manifest/deps/http/localhost_PORT3000/51a61f14fdad404fd2c9187363be7846d6d3b84a2b8697b9bd50c60d4509ab60.metadata.json @@ -0,0 +1,4 @@ +{ + "headers": {}, + "url": "http://localhost:3000/mod.ts" +}