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

Function fileURLToPath

lib/internal/url.js:1622–1631  ·  view source on GitHub ↗
(path, options = kEmptyObject)

Source from the content-addressed store, hash-verified

1620}
1621
1622function fileURLToPath(path, options = kEmptyObject) {
1623 const windows = options?.windows;
1624 if (typeof path === 'string')
1625 path = new URL(path);
1626 else if (!isURL(path))
1627 throw new ERR_INVALID_ARG_TYPE('path', ['string', 'URL'], path);
1628 if (path.protocol !== 'file:')
1629 throw new ERR_INVALID_URL_SCHEME('file');
1630 return (windows ?? isWindows) ? getPathFromURLWin32(path) : getPathFromURLPosix(path);
1631}
1632
1633// An alternative to fileURLToPath that outputs a Buffer
1634// instead of a string. The other fileURLToPath does not

Callers 15

pkgexports.mjsFile · 0.90
loadFunction · 0.90
eslint.config.mjsFile · 0.85
update-c-ares.mjsFile · 0.85
toPathIfFileURLFunction · 0.85
constructorMethod · 0.85
getRelativePathFunction · 0.85
parsePackageNameFunction · 0.85
getPackageJSONURLFunction · 0.85

Calls 3

getPathFromURLWin32Function · 0.85
getPathFromURLPosixFunction · 0.85
isURLFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…