MCPcopy Index your code
hub / github.com/nodejs/node / convertCJSFilenameToURL

Function convertCJSFilenameToURL

lib/internal/modules/customization_hooks.js:126–141  ·  view source on GitHub ↗

* @param {string} filename * @returns {string}

(filename)

Source from the content-addressed store, hash-verified

124 * @returns {string}
125 */
126function convertCJSFilenameToURL(filename) {
127 if (!filename) { return filename; }
128 let normalizedId = filename;
129 if (StringPrototypeStartsWith(filename, 'node:')) {
130 normalizedId = StringPrototypeSlice(filename, 5);
131 }
132 if (BuiltinModule.canBeRequiredByUsers(normalizedId)) {
133 return `node:${normalizedId}`;
134 }
135 // Handle the case where filename is neither a path, nor a built-in id,
136 // which is possible via monkey-patching.
137 if (isAbsolute(filename)) {
138 return pathToFileURL(filename).href;
139 }
140 return filename;
141}
142
143/**
144 * @param {string} url

Callers 5

resolveForCJSWithHooksFunction · 0.85
defaultResolveFunction · 0.85
defaultLoadImplFunction · 0.85
loader.jsFile · 0.85
loadSourceFunction · 0.85

Calls 3

isAbsoluteFunction · 0.85
canBeRequiredByUsersMethod · 0.80
pathToFileURLFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…