8000 lib: reduce url getters on `makeRequireFunction` by anonrig · Pull Request #48492 · nodejs/node · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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