[resolver] Stripe file:// from import paths

This commit is contained in:
Jarred Sumner
2022-07-11 06:03:43 -07:00
parent f6cd941522
commit 6190130626
2 changed files with 17 additions and 5 deletions

View File

@@ -1225,7 +1225,8 @@ pub const VirtualMachine = struct {
source
else
jsc_vm.bundler.fs.top_level_dir,
specifier,
// TODO: do we need to handle things like query string params?
if (strings.hasPrefixComptime(specifier, "file://")) specifier["file://".len..] else specifier,
.stmt,
);
@@ -1347,12 +1348,10 @@ pub const VirtualMachine = struct {
var slice = slice_;
if (slice.len == 0) return slice;
var was_http = false;
if (strings.hasPrefix(slice, "https://")) {
if (strings.hasPrefixComptime(slice, "https://")) {
slice = slice["https://".len..];
was_http = true;
}
if (strings.hasPrefix(slice, "http://")) {
} else if (strings.hasPrefixComptime(slice, "http://")) {
slice = slice["http://".len..];
was_http = true;
}
@@ -2781,12 +2780,17 @@ pub const HardcodedModule = enum {
.{ "node:fs/promises", "node:fs/promises" },
.{ "node:module", "node:module" },
.{ "node:path", "node:path" },
.{ "node:path/posix", "node:path" },
.{ "node:path/win32", "node:path" },
.{ "node:perf_hooks", "node:perf_hooks" },
.{ "node:streams/consumer", "node:streams/consumer" },
.{ "node:streams/web", "node:streams/web" },
.{ "node:timers", "node:timers" },
.{ "node:timers/promises", "node:timers/promises" },
.{ "node:url", "node:url" },
.{ "path", "node:path" },
.{ "path/posix", "node:path" },
.{ "path/win32", "node:path" },
.{ "perf_hooks", "node:perf_hooks" },
.{ "streams/consumer", "node:streams/consumer" },
.{ "streams/web", "node:streams/web" },