/opt/canhelp/node_modules/next/dist/shared/lib/router/utils
NameSizeModeActions
add-locale.d.ts3650644editdlrm
add-locale.js10490644editdlrm
add-locale.js.map17150644editdlrm
add-path-prefix.d.ts2000644editdlrm
add-path-prefix.js5360644editdlrm
add-path-prefix.js.map8850644editdlrm
add-path-suffix.d.ts2580644editdlrm
add-path-suffix.js5360644editdlrm
add-path-suffix.js.map9440644editdlrm
app-paths.d.ts9000644editdlrm
app-paths.js15040644editdlrm
app-paths.js.map27120644editdlrm
as-path-to-search-params.d.ts790644editdlrm
as-path-to-search-params.js4840644editdlrm
as-path-to-search-params.js.map5650644editdlrm
cache-busting-search-param.d.ts2570644editdlrm
cache-busting-search-param.js8320644editdlrm
cache-busting-search-param.js.map13150644editdlrm
compare-states.d.ts1460644editdlrm
compare-states.js10700644editdlrm
compare-states.js.map19310644editdlrm
disable-smooth-scroll.d.ts3040644editdlrm
disable-smooth-scroll.js25150644editdlrm
disable-smooth-scroll.js.map36210644editdlrm
escape-path-delimiters.d.ts960644editdlrm
escape-path-delimiters.js5080644editdlrm
escape-path-delimiters.js.map7530644editdlrm
format-next-pathname-info.d.ts2610644editdlrm
format-next-pathname-info.js12900644editdlrm
format-next-pathname-info.js.map20900644editdlrm
format-url.d.ts2160644editdlrm
format-url.js39550644editdlrm
format-url.js.map57390644editdlrm
get-asset-path-from-route.d.ts840644editdlrm
get-asset-path-from-route.js6390644editdlrm
get-asset-path-from-route.js.map8460644editdlrm
get-dynamic-param.d.ts27750644editdlrm
get-dynamic-param.js39760644editdlrm
get-dynamic-param.js.map74420644editdlrm
get-next-pathname-info.d.ts14500644editdlrm
get-next-pathname-info.js24790644editdlrm
get-next-pathname-info.js.map51780644editdlrm
get-route-from-asset-path.d.ts880644editdlrm
get-route-from-asset-path.js9310644editdlrm
get-route-from-asset-path.js.map13240644editdlrm
html-bots.d.ts530644editdlrm
html-bots.js11350644editdlrm
html-bots.js.map11450644editdlrm
index.d.ts1210644editdlrm
index.js7660644editdlrm
index.js.map4300644editdlrm
interception-routes.d.ts3120644editdlrm
interception-routes.js43540644editdlrm
interception-routes.js.map50540644editdlrm
interpolate-as.d.ts1950644editdlrm
interpolate-as.js22420644editdlrm
interpolate-as.js.map38010644editdlrm
is-bot.d.ts2910644editdlrm
is-bot.js17640644editdlrm
is-bot.js.map19980644editdlrm
is-dynamic.d.ts3160644editdlrm
is-dynamic.js8670644editdlrm
is-dynamic.js.map14890644editdlrm
is-local-url.d.ts1470644editdlrm
is-local-url.js8540644editdlrm
is-local-url.js.map12710644editdlrm
middleware-route-matcher.d.ts4630644editdlrm
middleware-route-matcher.js9470644editdlrm
middleware-route-matcher.js.map17620644editdlrm
omit.d.ts1260644editdlrm
omit.js4400644editdlrm
omit.js.map7780644editdlrm
parse-path.d.ts3200644editdlrm
parse-path.js10410644editdlrm
parse-path.js.map15100644editdlrm
parse-relative-url.d.ts7450644editdlrm
parse-relative-url.js14760644editdlrm
parse-relative-url.js.map30150644editdlrm
parse-url.d.ts3650644editdlrm
parse-url.js9540644editdlrm
parse-url.js.map18430644editdlrm
path-has-prefix.d.ts3640644editdlrm
path-has-prefix.js5350644editdlrm
path-has-prefix.js.map9960644editdlrm
path-match.d.ts9890644editdlrm
path-match.js19610644editdlrm
path-match.js.map37730644editdlrm
prepare-destination.d.ts15270644editdlrm
prepare-destination.js106370644editdlrm
prepare-destination.js.map171870644editdlrm
querystring.d.ts3480644editdlrm
querystring.js22810644editdlrm
querystring.js.map32870644editdlrm
relativize-url.d.ts6790644editdlrm
relativize-url.js11210644editdlrm
relativize-url.js.map18720644editdlrm
remove-path-prefix.d.ts3890644editdlrm
remove-path-prefix.js12610644editdlrm
remove-path-prefix.js.map20000644editdlrm
remove-trailing-slash.d.ts2590644editdlrm
remove-trailing-slash.js5520644editdlrm
remove-trailing-slash.js.map5980644editdlrm
resolve-rewrites.d.ts6820644editdlrm
resolve-rewrites.js46700644editdlrm
resolve-rewrites.js.map77810644editdlrm
route-match-utils.d.ts15130644editdlrm
route-match-utils.js36750644editdlrm
route-match-utils.js.map57540644editdlrm
route-matcher.d.ts3840644editdlrm
route-matcher.js15090644editdlrm
route-matcher.js.map25580644editdlrm
route-regex.d.ts34920644editdlrm
route-regex.js94980644editdlrm
route-regex.js.map175770644editdlrm
sortable-routes.d.ts42490644editdlrm
sortable-routes.js63210644editdlrm
sortable-routes.js.map125300644editdlrm
sorted-routes.d.ts3440644editdlrm
sorted-routes.js116640644editdlrm
sorted-routes.js.map147880644editdlrm
Edit: /opt/canhelp/node_modules/next/dist/shared/lib/router/utils/prepare-destination.js (10637B)
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 0 && (module.exports = { compileNonPath: null, matchHas: null, parseDestination: null, prepareDestination: null }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: all[name] }); } _export(exports, { compileNonPath: function() { return compileNonPath; }, matchHas: function() { return matchHas; }, parseDestination: function() { return parseDestination; }, prepareDestination: function() { return prepareDestination; } }); const _escaperegexp = require("../../escape-regexp"); const _parseurl = require("./parse-url"); const _interceptionroutes = require("./interception-routes"); const _getcookieparser = require("../../../../server/api-utils/get-cookie-parser"); const _routematchutils = require("./route-match-utils"); /** * Ensure only a-zA-Z are used for param names for proper interpolating * with path-to-regexp */ function getSafeParamName(paramName) { let newParamName = ''; for(let i = 0; i < paramName.length; i++){ const charCode = paramName.charCodeAt(i); if (charCode > 64 && charCode < 91 || // A-Z charCode > 96 && charCode < 123 // a-z ) { newParamName += paramName[i]; } } return newParamName; } function escapeSegment(str, segmentName) { return str.replace(new RegExp(":" + (0, _escaperegexp.escapeStringRegexp)(segmentName), 'g'), "__ESC_COLON_" + segmentName); } function unescapeSegments(str) { return str.replace(/__ESC_COLON_/gi, ':'); } function matchHas(req, query, has, missing) { if (has === void 0) has = []; if (missing === void 0) missing = []; const params = {}; const hasMatch = (hasItem)=>{ let value; let key = hasItem.key; switch(hasItem.type){ case 'header': { key = key.toLowerCase(); value = req.headers[key]; break; } case 'cookie': { if ('cookies' in req) { value = req.cookies[hasItem.key]; } else { const cookies = (0, _getcookieparser.getCookieParser)(req.headers)(); value = cookies[hasItem.key]; } break; } case 'query': { value = query[key]; break; } case 'host': { const { host } = (req == null ? void 0 : req.headers) || {}; // remove port from host if present const hostname = host == null ? void 0 : host.split(':', 1)[0].toLowerCase(); value = hostname; break; } default: { break; } } if (!hasItem.value && value) { params[getSafeParamName(key)] = value; return true; } else if (value) { const matcher = new RegExp("^" + hasItem.value + "$"); const matches = Array.isArray(value) ? value.slice(-1)[0].match(matcher) : value.match(matcher); if (matches) { if (Array.isArray(matches)) { if (matches.groups) { Object.keys(matches.groups).forEach((groupKey)=>{ params[groupKey] = matches.groups[groupKey]; }); } else if (hasItem.type === 'host' && matches[0]) { params.host = matches[0]; } } return true; } } return false; }; const allMatch = has.every((item)=>hasMatch(item)) && !missing.some((item)=>hasMatch(item)); if (allMatch) { return params; } return false; } function compileNonPath(value, params) { if (!value.includes(':')) { return value; } for (const key of Object.keys(params)){ if (value.includes(":" + key)) { value = value.replace(new RegExp(":" + key + "\\*", 'g'), ":" + key + "--ESCAPED_PARAM_ASTERISKS").replace(new RegExp(":" + key + "\\?", 'g'), ":" + key + "--ESCAPED_PARAM_QUESTION").replace(new RegExp(":" + key + "\\+", 'g'), ":" + key + "--ESCAPED_PARAM_PLUS").replace(new RegExp(":" + key + "(?!\\w)", 'g'), "--ESCAPED_PARAM_COLON" + key); } } value = value.replace(/(:|\*|\?|\+|\(|\)|\{|\})/g, '\\$1').replace(/--ESCAPED_PARAM_PLUS/g, '+').replace(/--ESCAPED_PARAM_COLON/g, ':').replace(/--ESCAPED_PARAM_QUESTION/g, '?').replace(/--ESCAPED_PARAM_ASTERISKS/g, '*'); // the value needs to start with a forward-slash to be compiled // correctly return (0, _routematchutils.safeCompile)("/" + value, { validate: false })(params).slice(1); } function parseDestination(args) { let escaped = args.destination; for (const param of Object.keys({ ...args.params, ...args.query })){ if (!param) continue; escaped = escapeSegment(escaped, param); } const parsed = (0, _parseurl.parseUrl)(escaped); let pathname = parsed.pathname; if (pathname) { pathname = unescapeSegments(pathname); } let href = parsed.href; if (href) { href = unescapeSegments(href); } let hostname = parsed.hostname; if (hostname) { hostname = unescapeSegments(hostname); } let hash = parsed.hash; if (hash) { hash = unescapeSegments(hash); } let search = parsed.search; if (search) { search = unescapeSegments(search); } return { ...parsed, pathname, hostname, href, hash, search }; } function prepareDestination(args) { const parsedDestination = parseDestination(args); const { hostname: destHostname, query: destQuery, search: destSearch } = parsedDestination; // The following code assumes that the pathname here includes the hash if it's // present. let destPath = parsedDestination.pathname; if (parsedDestination.hash) { destPath = "" + destPath + parsedDestination.hash; } const destParams = []; const destPathParamKeys = []; (0, _routematchutils.safePathToRegexp)(destPath, destPathParamKeys); for (const key of destPathParamKeys){ destParams.push(key.name); } if (destHostname) { const destHostnameParamKeys = []; (0, _routematchutils.safePathToRegexp)(destHostname, destHostnameParamKeys); for (const key of destHostnameParamKeys){ destParams.push(key.name); } } const destPathCompiler = (0, _routematchutils.safeCompile)(destPath, // we don't validate while compiling the destination since we should // have already validated before we got to this point and validating // breaks compiling destinations with named pattern params from the source // e.g. /something:hello(.*) -> /another/:hello is broken with validation // since compile validation is meant for reversing and not for inserting // params from a separate path-regex into another { validate: false }); let destHostnameCompiler; if (destHostname) { destHostnameCompiler = (0, _routematchutils.safeCompile)(destHostname, { validate: false }); } // update any params in query values for (const [key, strOrArray] of Object.entries(destQuery)){ // the value needs to start with a forward-slash to be compiled // correctly if (Array.isArray(strOrArray)) { destQuery[key] = strOrArray.map((value)=>compileNonPath(unescapeSegments(value), args.params)); } else if (typeof strOrArray === 'string') { destQuery[key] = compileNonPath(unescapeSegments(strOrArray), args.params); } } // add path params to query if it's not a redirect and not // already defined in destination query or path let paramKeys = Object.keys(args.params).filter((name)=>name !== 'nextInternalLocale'); if (args.appendParamsToQuery && !paramKeys.some((key)=>destParams.includes(key))) { for (const key of paramKeys){ if (!(key in destQuery)) { destQuery[key] = args.params[key]; } } } let newUrl; // The compiler also that the interception route marker is an unnamed param, hence '0', // so we need to add it to the params object. if ((0, _interceptionroutes.isInterceptionRouteAppPath)(destPath)) { for (const segment of destPath.split('/')){ const marker = _interceptionroutes.INTERCEPTION_ROUTE_MARKERS.find((m)=>segment.startsWith(m)); if (marker) { if (marker === '(..)(..)') { args.params['0'] = '(..)'; args.params['1'] = '(..)'; } else { args.params['0'] = marker; } break; } } } try { newUrl = destPathCompiler(args.params); const [pathname, hash] = newUrl.split('#', 2); if (destHostnameCompiler) { parsedDestination.hostname = destHostnameCompiler(args.params); } parsedDestination.pathname = pathname; parsedDestination.hash = "" + (hash ? '#' : '') + (hash || ''); parsedDestination.search = destSearch ? compileNonPath(destSearch, args.params) : ''; } catch (err) { if (err.message.match(/Expected .*? to not repeat, but got an array/)) { throw Object.defineProperty(new Error("To use a multi-match in the destination you must add `*` at the end of the param name to signify it should repeat. https://nextjs.org/docs/messages/invalid-multi-match"), "__NEXT_ERROR_CODE", { value: "E329", enumerable: false, configurable: true }); } throw err; } // Query merge order lowest priority to highest // 1. initial URL query values // 2. path segment values // 3. destination specified query values parsedDestination.query = { ...args.query, ...parsedDestination.query }; return { newUrl, destQuery, parsedDestination }; } //# sourceMappingURL=prepare-destination.js.map