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

Function invalidPackageTarget

lib/internal/modules/esm/resolve.js:346–356  ·  view source on GitHub ↗

* Creates an error object for an invalid package target. * @param {string} subpath - The subpath. * @param {import('internal/modules/esm/package_config.js').PackageTarget} target - The target. * @param {URL} packageJSONUrl - The URL of the package.json file. * @param {boolean} internal - Whether

(
  subpath, target, packageJSONUrl, internal, base)

Source from the content-addressed store, hash-verified

344 * @returns {ERR_INVALID_PACKAGE_TARGET} - The error object.
345 */
346function invalidPackageTarget(
347 subpath, target, packageJSONUrl, internal, base) {
348 if (typeof target === 'object' && target !== null) {
349 target = JSONStringify(target, null, '');
350 } else {
351 target = `${target}`;
352 }
353 return new ERR_INVALID_PACKAGE_TARGET(
354 fileURLToPath(new URL('.', packageJSONUrl)), subpath, target,
355 internal, base && fileURLToPath(base));
356}
357
358const invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
359const deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;

Callers 2

resolvePackageTargetFunction · 0.85

Calls 1

fileURLToPathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…