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

Function normalizeReferrerURL

lib/internal/modules/helpers.js:331–350  ·  view source on GitHub ↗

* Normalize the referrer name as a URL. * If it's a string containing an absolute path or a URL it's normalized as * a URL string. * Otherwise it's returned as undefined. * @param {string | null | undefined} referrerName * @returns {string | undefined}

(referrerName)

Source from the content-addressed store, hash-verified

329 * @returns {string | undefined}
330 */
331function normalizeReferrerURL(referrerName) {
332 if (referrerName === null || referrerName === undefined) {
333 return undefined;
334 }
335
336 if (typeof referrerName === 'string') {
337 if (path.isAbsolute(referrerName)) {
338 return pathToFileURL(referrerName).href;
339 }
340
341 if (StringPrototypeStartsWith(referrerName, 'file://') ||
342 URLCanParse(referrerName)) {
343 return referrerName;
344 }
345
346 return undefined;
347 }
348
349 assert.fail('Unreachable code reached by ' + inspect(referrerName));
350}
351
352/**
353 * Coerce a URL string to a filename. This is used by the ESM loader

Callers 2

maybeCacheSourceMapFunction · 0.85

Calls 3

pathToFileURLFunction · 0.50
inspectFunction · 0.50
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…