Skip to content

Commit 3b11105

Browse files
fixup!: urlToFilename
1 parent 585ac6d commit 3b11105

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/internal/modules/esm/translators.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const { dirname, extname, isAbsolute } = require('path');
4141
const {
4242
loadBuiltinModule,
4343
stripBOM,
44+
urlToFilename,
4445
} = require('internal/modules/helpers');
4546
const {
4647
kIsCachedByESMLoader,
@@ -243,7 +244,7 @@ function loadCJSModule(module, source, url, filename) {
243244
}
244245
}
245246
const { url: resolvedURL } = cascadedLoader.resolveSync(specifier, url, kEmptyObject);
246-
return StringPrototypeStartsWith(resolvedURL, 'file://') ? fileURLToPath(resolvedURL) : resolvedURL;
247+
return urlToFilename(resolvedURL);
247248
});
248249
setOwnProperty(requireFn, 'main', process.mainModule);
249250

@@ -265,7 +266,7 @@ const cjsCache = new SafeMap();
265266
function createCJSModuleWrap(url, source, isMain, loadCJS = loadCJSModule) {
266267
debug(`Translating CJSModule ${url}`);
267268

268-
const filename = StringPrototypeStartsWith(url, 'file://') ? fileURLToPath(url) : url;
269+
const filename = urlToFilename(url);
269270
// In case the source was not provided by the `load` step, we need fetch it now.
270271
source = stringify(source ?? getSource(new URL(url)).source);
271272

0 commit comments

Comments
 (0)