aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js')
-rw-r--r--src/bun.js/bindings/ImportMetaObject.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bun.js/bindings/ImportMetaObject.cpp b/src/bun.js/bindings/ImportMetaObject.cpp
index b3b1a6a94..ab61072af 100644
--- a/src/bun.js/bindings/ImportMetaObject.cpp
+++ b/src/bun.js/bindings/ImportMetaObject.cpp
@@ -349,8 +349,12 @@ JSC_DEFINE_HOST_FUNCTION(functionImportMeta__resolve,
return JSC::JSValue::encode(JSC::JSValue {});
}
- // Stringified URL to a file, going off assumption that all modules would be file URLs
- RELEASE_AND_RETURN(scope, JSValue::encode(jsString(vm, makeString("file://"_s, result.toWTFString(globalObject)))));
+ auto resultString = result.toWTFString(globalObject);
+ if (resultString.startsWith("/"_s)) {
+ // file path -> url
+ RELEASE_AND_RETURN(scope, JSValue::encode(jsString(vm, WTF::URL::fileURLWithFileSystemPath(resultString).string())));
+ }
+ return JSValue::encode(result);
}
enum class ImportMetaPropertyOffset : uint32_t {