/opt/canhelp/node_modules/next/dist/esm/shared/lib/router/utils
NameSizeModeActions
add-locale.js10200644editdlrm
add-locale.js.map17200644editdlrm
add-path-prefix.js4320644editdlrm
add-path-prefix.js.map8880644editdlrm
add-path-suffix.js4900644editdlrm
add-path-suffix.js.map9480644editdlrm
app-paths.js17680644editdlrm
app-paths.js.map27220644editdlrm
as-path-to-search-params.js2620644editdlrm
as-path-to-search-params.js.map5490644editdlrm
cache-busting-search-param.js5800644editdlrm
cache-busting-search-param.js.map13070644editdlrm
compare-states.js8500644editdlrm
compare-states.js.map19140644editdlrm
disable-smooth-scroll.js23760644editdlrm
disable-smooth-scroll.js.map36260644editdlrm
escape-path-delimiters.js3070644editdlrm
escape-path-delimiters.js.map7370644editdlrm
format-next-pathname-info.js9080644editdlrm
format-next-pathname-info.js.map20790644editdlrm
format-url.js32690644editdlrm
format-url.js.map56970644editdlrm
get-asset-path-from-route.js4370644editdlrm
get-asset-path-from-route.js.map8300644editdlrm
get-dynamic-param.js53080644editdlrm
get-dynamic-param.js.map74360644editdlrm
get-next-pathname-info.js21580644editdlrm
get-next-pathname-info.js.map51770644editdlrm
get-route-from-asset-path.js7160644editdlrm
get-route-from-asset-path.js.map13160644editdlrm
html-bots.js9090644editdlrm
html-bots.js.map11360644editdlrm
index.js1550644editdlrm
index.js.map3890644editdlrm
interception-routes.js37080644editdlrm
interception-routes.js.map50160644editdlrm
interpolate-as.js20000644editdlrm
interpolate-as.js.map38050644editdlrm
is-bot.js11000644editdlrm
is-bot.js.map19470644editdlrm
is-dynamic.js8840644editdlrm
is-dynamic.js.map15040644editdlrm
is-local-url.js7220644editdlrm
is-local-url.js.map12820644editdlrm
middleware-route-matcher.js6780644editdlrm
middleware-route-matcher.js.map17550644editdlrm
omit.js2500644editdlrm
omit.js.map7610644editdlrm
parse-path.js8410644editdlrm
parse-path.js.map14950644editdlrm
parse-relative-url.js12510644editdlrm
parse-relative-url.js.map30150644editdlrm
parse-url.js7220644editdlrm
parse-url.js.map18500644editdlrm
path-has-prefix.js5950644editdlrm
path-has-prefix.js.map10020644editdlrm
path-match.js19700644editdlrm
path-match.js.map37910644editdlrm
prepare-destination.js98280644editdlrm
prepare-destination.js.map171430644editdlrm
querystring.js17030644editdlrm
querystring.js.map32240644editdlrm
relativize-url.js8510644editdlrm
relativize-url.js.map18390644editdlrm
remove-path-prefix.js13340644editdlrm
remove-path-prefix.js.map20090644editdlrm
remove-trailing-slash.js3320644editdlrm
remove-trailing-slash.js.map5830644editdlrm
resolve-rewrites.js42400644editdlrm
resolve-rewrites.js.map78050644editdlrm
route-match-utils.js33610644editdlrm
route-match-utils.js.map56600644editdlrm
route-matcher.js12710644editdlrm
route-matcher.js.map25670644editdlrm
route-regex.js93150644editdlrm
route-regex.js.map175260644editdlrm
sortable-routes.js85020644editdlrm
sortable-routes.js.map125360644editdlrm
sorted-routes.js113320644editdlrm
sorted-routes.js.map147570644editdlrm
Edit: /opt/canhelp/node_modules/next/dist/esm/shared/lib/router/utils/route-regex.js (9315B)
import { NEXT_INTERCEPTION_MARKER_PREFIX, NEXT_QUERY_PARAM_PREFIX } from '../../../../lib/constants'; import { INTERCEPTION_ROUTE_MARKERS } from './interception-routes'; import { escapeStringRegexp } from '../../escape-regexp'; import { removeTrailingSlash } from './remove-trailing-slash'; import { PARAMETER_PATTERN, parseMatchedParameter } from './get-dynamic-param'; function getParametrizedRoute(route, includeSuffix, includePrefix) { const groups = {}; let groupIndex = 1; const segments = []; for (const segment of removeTrailingSlash(route).slice(1).split('/')){ const markerMatch = INTERCEPTION_ROUTE_MARKERS.find((m)=>segment.startsWith(m)); const paramMatches = segment.match(PARAMETER_PATTERN) // Check for parameters ; if (markerMatch && paramMatches && paramMatches[2]) { const { key, optional, repeat } = parseMatchedParameter(paramMatches[2]); groups[key] = { pos: groupIndex++, repeat, optional }; segments.push("/" + escapeStringRegexp(markerMatch) + "([^/]+?)"); } else if (paramMatches && paramMatches[2]) { const { key, repeat, optional } = parseMatchedParameter(paramMatches[2]); groups[key] = { pos: groupIndex++, repeat, optional }; if (includePrefix && paramMatches[1]) { segments.push("/" + escapeStringRegexp(paramMatches[1])); } let s = repeat ? optional ? '(?:/(.+?))?' : '/(.+?)' : '/([^/]+?)'; // Remove the leading slash if includePrefix already added it. if (includePrefix && paramMatches[1]) { s = s.substring(1); } segments.push(s); } else { segments.push("/" + escapeStringRegexp(segment)); } // If there's a suffix, add it to the segments if it's enabled. if (includeSuffix && paramMatches && paramMatches[3]) { segments.push(escapeStringRegexp(paramMatches[3])); } } return { parameterizedRoute: segments.join(''), groups }; } /** * From a normalized route this function generates a regular expression and * a corresponding groups object intended to be used to store matching groups * from the regular expression. */ export function getRouteRegex(normalizedRoute, param) { let { includeSuffix = false, includePrefix = false, excludeOptionalTrailingSlash = false } = param === void 0 ? {} : param; const { parameterizedRoute, groups } = getParametrizedRoute(normalizedRoute, includeSuffix, includePrefix); let re = parameterizedRoute; if (!excludeOptionalTrailingSlash) { re += '(?:/)?'; } return { re: new RegExp("^" + re + "$"), groups: groups }; } /** * Builds a function to generate a minimal routeKey using only a-z and minimal * number of characters. */ function buildGetSafeRouteKey() { let i = 0; return ()=>{ let routeKey = ''; let j = ++i; while(j > 0){ routeKey += String.fromCharCode(97 + (j - 1) % 26); j = Math.floor((j - 1) / 26); } return routeKey; }; } function getSafeKeyFromSegment(param) { let { interceptionMarker, getSafeRouteKey, segment, routeKeys, keyPrefix, backreferenceDuplicateKeys } = param; const { key, optional, repeat } = parseMatchedParameter(segment); // replace any non-word characters since they can break // the named regex let cleanedKey = key.replace(/\W/g, ''); if (keyPrefix) { cleanedKey = "" + keyPrefix + cleanedKey; } let invalidKey = false; // check if the key is still invalid and fallback to using a known // safe key if (cleanedKey.length === 0 || cleanedKey.length > 30) { invalidKey = true; } if (!isNaN(parseInt(cleanedKey.slice(0, 1)))) { invalidKey = true; } if (invalidKey) { cleanedKey = getSafeRouteKey(); } const duplicateKey = cleanedKey in routeKeys; if (keyPrefix) { routeKeys[cleanedKey] = "" + keyPrefix + key; } else { routeKeys[cleanedKey] = key; } // if the segment has an interception marker, make sure that's part of the regex pattern // this is to ensure that the route with the interception marker doesn't incorrectly match // the non-intercepted route (ie /app/(.)[username] should not match /app/[username]) const interceptionPrefix = interceptionMarker ? escapeStringRegexp(interceptionMarker) : ''; let pattern; if (duplicateKey && backreferenceDuplicateKeys) { // Use a backreference to the key to ensure that the key is the same value // in each of the placeholders. pattern = "\\k<" + cleanedKey + ">"; } else if (repeat) { pattern = "(?<" + cleanedKey + ">.+?)"; } else { pattern = "(?<" + cleanedKey + ">[^/]+?)"; } return optional ? "(?:/" + interceptionPrefix + pattern + ")?" : "/" + interceptionPrefix + pattern; } function getNamedParametrizedRoute(route, prefixRouteKeys, includeSuffix, includePrefix, backreferenceDuplicateKeys) { const getSafeRouteKey = buildGetSafeRouteKey(); const routeKeys = {}; const segments = []; for (const segment of removeTrailingSlash(route).slice(1).split('/')){ const hasInterceptionMarker = INTERCEPTION_ROUTE_MARKERS.some((m)=>segment.startsWith(m)); const paramMatches = segment.match(PARAMETER_PATTERN) // Check for parameters ; if (hasInterceptionMarker && paramMatches && paramMatches[2]) { // If there's an interception marker, add it to the segments. segments.push(getSafeKeyFromSegment({ getSafeRouteKey, interceptionMarker: paramMatches[1], segment: paramMatches[2], routeKeys, keyPrefix: prefixRouteKeys ? NEXT_INTERCEPTION_MARKER_PREFIX : undefined, backreferenceDuplicateKeys })); } else if (paramMatches && paramMatches[2]) { // If there's a prefix, add it to the segments if it's enabled. if (includePrefix && paramMatches[1]) { segments.push("/" + escapeStringRegexp(paramMatches[1])); } let s = getSafeKeyFromSegment({ getSafeRouteKey, segment: paramMatches[2], routeKeys, keyPrefix: prefixRouteKeys ? NEXT_QUERY_PARAM_PREFIX : undefined, backreferenceDuplicateKeys }); // Remove the leading slash if includePrefix already added it. if (includePrefix && paramMatches[1]) { s = s.substring(1); } segments.push(s); } else { segments.push("/" + escapeStringRegexp(segment)); } // If there's a suffix, add it to the segments if it's enabled. if (includeSuffix && paramMatches && paramMatches[3]) { segments.push(escapeStringRegexp(paramMatches[3])); } } return { namedParameterizedRoute: segments.join(''), routeKeys }; } /** * This function extends `getRouteRegex` generating also a named regexp where * each group is named along with a routeKeys object that indexes the assigned * named group with its corresponding key. When the routeKeys need to be * prefixed to uniquely identify internally the "prefixRouteKey" arg should * be "true" currently this is only the case when creating the routes-manifest * during the build */ export function getNamedRouteRegex(normalizedRoute, options) { var _options_includeSuffix, _options_includePrefix, _options_backreferenceDuplicateKeys; const result = getNamedParametrizedRoute(normalizedRoute, options.prefixRouteKeys, (_options_includeSuffix = options.includeSuffix) != null ? _options_includeSuffix : false, (_options_includePrefix = options.includePrefix) != null ? _options_includePrefix : false, (_options_backreferenceDuplicateKeys = options.backreferenceDuplicateKeys) != null ? _options_backreferenceDuplicateKeys : false); let namedRegex = result.namedParameterizedRoute; if (!options.excludeOptionalTrailingSlash) { namedRegex += '(?:/)?'; } return { ...getRouteRegex(normalizedRoute, options), namedRegex: "^" + namedRegex + "$", routeKeys: result.routeKeys }; } /** * Generates a named regexp. * This is intended to be using for build time only. */ export function getNamedMiddlewareRegex(normalizedRoute, options) { const { parameterizedRoute } = getParametrizedRoute(normalizedRoute, false, false); const { catchAll = true } = options; if (parameterizedRoute === '/') { let catchAllRegex = catchAll ? '.*' : ''; return { namedRegex: "^/" + catchAllRegex + "$" }; } const { namedParameterizedRoute } = getNamedParametrizedRoute(normalizedRoute, false, false, false, false); let catchAllGroupedRegex = catchAll ? '(?:(/.*)?)' : ''; return { namedRegex: "^" + namedParameterizedRoute + catchAllGroupedRegex + "$" }; } //# sourceMappingURL=route-regex.js.map