Skip to content

Commit 06693a1

Browse files
fixup!: urlToFilename
1 parent 2cc1f24 commit 06693a1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/internal/modules/esm/translators.js

+3-2
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
cjsExportsCache,
@@ -242,7 +243,7 @@ function loadCJSModule(module, source, url, filename) {
242243
}
243244
}
244245
const { url: resolvedURL } = cascadedLoader.resolveSync(specifier, url, kEmptyObject);
245-
return StringPrototypeStartsWith(resolvedURL, 'file://') ? fileURLToPath(resolvedURL) : resolvedURL;
246+
return urlToFilename(resolvedURL);
246247
});
247248
setOwnProperty(requireFn, 'main', process.mainModule);
248249

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

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

0 commit comments

Comments
 (0)