diff options
author | 2023-09-19 21:00:12 -0700 | |
---|---|---|
committer | 2023-09-19 21:00:12 -0700 | |
commit | a9199bcfe3635de7914dfb679e14c1f33d2b65fd (patch) | |
tree | 0f520933eb58faad896fd58d3d1a938954e7dd7b /src/bun.js/bindings/ImportMetaObject.cpp | |
parent | 94fc2a7be96e0a0c6fbed8ccb7b483b562f1de5f (diff) | |
download | bun-a9199bcfe3635de7914dfb679e14c1f33d2b65fd.tar.gz bun-a9199bcfe3635de7914dfb679e14c1f33d2b65fd.tar.zst bun-a9199bcfe3635de7914dfb679e14c1f33d2b65fd.zip |
Diffstat (limited to 'src/bun.js/bindings/ImportMetaObject.cpp')
-rw-r--r-- | src/bun.js/bindings/ImportMetaObject.cpp | 8 |
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 { |