* 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)
| 344 | * @returns {ERR_INVALID_PACKAGE_TARGET} - The error object. |
| 345 | */ |
| 346 | function 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 | |
| 358 | const 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; |
| 359 | const 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; |
no test coverage detected
searching dependent graphs…