/
opt
/
canhelp
/
node_modules
/
next
/
dist
/
esm
/
shared
/
lib
/
router
/
utils
/
/opt/canhelp/node_modules/next/dist/esm/shared/lib/router/utils
mkdir
upload
Name
Size
Mode
Actions
add-locale.js
1020
0644
edit
dl
rm
add-locale.js.map
1720
0644
edit
dl
rm
add-path-prefix.js
432
0644
edit
dl
rm
add-path-prefix.js.map
888
0644
edit
dl
rm
add-path-suffix.js
490
0644
edit
dl
rm
add-path-suffix.js.map
948
0644
edit
dl
rm
app-paths.js
1768
0644
edit
dl
rm
app-paths.js.map
2722
0644
edit
dl
rm
as-path-to-search-params.js
262
0644
edit
dl
rm
as-path-to-search-params.js.map
549
0644
edit
dl
rm
cache-busting-search-param.js
580
0644
edit
dl
rm
cache-busting-search-param.js.map
1307
0644
edit
dl
rm
compare-states.js
850
0644
edit
dl
rm
compare-states.js.map
1914
0644
edit
dl
rm
disable-smooth-scroll.js
2376
0644
edit
dl
rm
disable-smooth-scroll.js.map
3626
0644
edit
dl
rm
escape-path-delimiters.js
307
0644
edit
dl
rm
escape-path-delimiters.js.map
737
0644
edit
dl
rm
format-next-pathname-info.js
908
0644
edit
dl
rm
format-next-pathname-info.js.map
2079
0644
edit
dl
rm
format-url.js
3269
0644
edit
dl
rm
format-url.js.map
5697
0644
edit
dl
rm
get-asset-path-from-route.js
437
0644
edit
dl
rm
get-asset-path-from-route.js.map
830
0644
edit
dl
rm
get-dynamic-param.js
5308
0644
edit
dl
rm
get-dynamic-param.js.map
7436
0644
edit
dl
rm
get-next-pathname-info.js
2158
0644
edit
dl
rm
get-next-pathname-info.js.map
5177
0644
edit
dl
rm
get-route-from-asset-path.js
716
0644
edit
dl
rm
get-route-from-asset-path.js.map
1316
0644
edit
dl
rm
html-bots.js
909
0644
edit
dl
rm
html-bots.js.map
1136
0644
edit
dl
rm
index.js
155
0644
edit
dl
rm
index.js.map
389
0644
edit
dl
rm
interception-routes.js
3708
0644
edit
dl
rm
interception-routes.js.map
5016
0644
edit
dl
rm
interpolate-as.js
2000
0644
edit
dl
rm
interpolate-as.js.map
3805
0644
edit
dl
rm
is-bot.js
1100
0644
edit
dl
rm
is-bot.js.map
1947
0644
edit
dl
rm
is-dynamic.js
884
0644
edit
dl
rm
is-dynamic.js.map
1504
0644
edit
dl
rm
is-local-url.js
722
0644
edit
dl
rm
is-local-url.js.map
1282
0644
edit
dl
rm
middleware-route-matcher.js
678
0644
edit
dl
rm
middleware-route-matcher.js.map
1755
0644
edit
dl
rm
omit.js
250
0644
edit
dl
rm
omit.js.map
761
0644
edit
dl
rm
parse-path.js
841
0644
edit
dl
rm
parse-path.js.map
1495
0644
edit
dl
rm
parse-relative-url.js
1251
0644
edit
dl
rm
parse-relative-url.js.map
3015
0644
edit
dl
rm
parse-url.js
722
0644
edit
dl
rm
parse-url.js.map
1850
0644
edit
dl
rm
path-has-prefix.js
595
0644
edit
dl
rm
path-has-prefix.js.map
1002
0644
edit
dl
rm
path-match.js
1970
0644
edit
dl
rm
path-match.js.map
3791
0644
edit
dl
rm
prepare-destination.js
9828
0644
edit
dl
rm
prepare-destination.js.map
17143
0644
edit
dl
rm
querystring.js
1703
0644
edit
dl
rm
querystring.js.map
3224
0644
edit
dl
rm
relativize-url.js
851
0644
edit
dl
rm
relativize-url.js.map
1839
0644
edit
dl
rm
remove-path-prefix.js
1334
0644
edit
dl
rm
remove-path-prefix.js.map
2009
0644
edit
dl
rm
remove-trailing-slash.js
332
0644
edit
dl
rm
remove-trailing-slash.js.map
583
0644
edit
dl
rm
resolve-rewrites.js
4240
0644
edit
dl
rm
resolve-rewrites.js.map
7805
0644
edit
dl
rm
route-match-utils.js
3361
0644
edit
dl
rm
route-match-utils.js.map
5660
0644
edit
dl
rm
route-matcher.js
1271
0644
edit
dl
rm
route-matcher.js.map
2567
0644
edit
dl
rm
route-regex.js
9315
0644
edit
dl
rm
route-regex.js.map
17526
0644
edit
dl
rm
sortable-routes.js
8502
0644
edit
dl
rm
sortable-routes.js.map
12536
0644
edit
dl
rm
sorted-routes.js
11332
0644
edit
dl
rm
sorted-routes.js.map
14757
0644
edit
dl
rm
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
Save
cmd:
run