Skip to content

Commit

Permalink
lib: reduce url getters on makeRequireFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jun 23, 2023
1 parent e934003 commit 1081b87
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/internal/modules/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,18 @@ function makeRequireFunction(mod, redirects) {
if (destination === true) {
missing = false;
} else if (destination) {
const href = destination.href;
if (destination.protocol === 'node:') {
const { href, protocol } = destination;
if (protocol === 'node:') {
const specifier = destination.pathname;

if (BuiltinModule.canBeRequiredByUsers(specifier)) {
const mod = loadBuiltinModule(specifier, href);
return mod.exports;
}
throw new ERR_UNKNOWN_BUILTIN_MODULE(specifier);
} else if (destination.protocol === 'file:') {
let filepath;
if (urlToFileCache.has(href)) {
filepath = urlToFileCache.get(href);
} else {
} else if (protocol === 'file:') {
let filepath = urlToFileCache.get(href);
if (!filepath) {
filepath = fileURLToPath(destination);
urlToFileCache.set(href, filepath);
}
Expand Down

0 comments on commit 1081b87

Please sign in to comment.