* 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)
| 329 | * @returns {string | undefined} |
| 330 | */ |
| 331 | function 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 |
no test coverage detected
searching dependent graphs…