/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/get-dynamic-param.js (5308B)
/** * * Shared logic on client and server for creating a dynamic param value. * * This code needs to be shared with the client so it can extract dynamic route * params from the URL without a server request. * * Because everything in this module is sent to the client, we should aim to * keep this code as simple as possible. The special case handling for catchall * and optional is, alas, unfortunate. */ export function getDynamicParam(params, segmentKey, dynamicParamType, pagePath, fallbackRouteParams) { let value = params[segmentKey]; if (fallbackRouteParams && fallbackRouteParams.has(segmentKey)) { value = fallbackRouteParams.get(segmentKey); } else if (Array.isArray(value)) { value = value.map((i)=>encodeURIComponent(i)); } else if (typeof value === 'string') { value = encodeURIComponent(value); } if (!value) { const isCatchall = dynamicParamType === 'c'; const isOptionalCatchall = dynamicParamType === 'oc'; if (isCatchall || isOptionalCatchall) { // handle the case where an optional catchall does not have a value, // e.g. `/dashboard/[[...slug]]` when requesting `/dashboard` if (isOptionalCatchall) { return { param: segmentKey, value: null, type: dynamicParamType, treeSegment: [ segmentKey, '', dynamicParamType ] }; } // handle the case where a catchall or optional catchall does not have a value, // e.g. `/foo/bar/hello` and `@slot/[...catchall]` or `@slot/[[...catchall]]` is matched value = pagePath.split('/')// remove the first empty string .slice(1)// replace any dynamic params with the actual values .flatMap((pathSegment)=>{ const param = parseParameter(pathSegment); var _params_param_key; // if the segment matches a param, return the param value // otherwise, it's a static segment, so just return that return (_params_param_key = params[param.key]) != null ? _params_param_key : param.key; }); return { param: segmentKey, value, type: dynamicParamType, // This value always has to be a string. treeSegment: [ segmentKey, value.join('/'), dynamicParamType ] }; } } return { param: segmentKey, // The value that is passed to user code. value: value, // The value that is rendered in the router tree. treeSegment: [ segmentKey, Array.isArray(value) ? value.join('/') : value, dynamicParamType ], type: dynamicParamType }; } /** * Regular expression pattern used to match route parameters. * Matches both single parameters and parameter groups. * Examples: * - `[[...slug]]` matches parameter group with key 'slug', repeat: true, optional: true * - `[...slug]` matches parameter group with key 'slug', repeat: true, optional: false * - `[[foo]]` matches parameter with key 'foo', repeat: false, optional: true * - `[bar]` matches parameter with key 'bar', repeat: false, optional: false */ export const PARAMETER_PATTERN = /^([^[]*)\[((?:\[[^\]]*\])|[^\]]+)\](.*)$/; /** * Parses a given parameter from a route to a data structure that can be used * to generate the parametrized route. * Examples: * - `[[...slug]]` -> `{ key: 'slug', repeat: true, optional: true }` * - `[...slug]` -> `{ key: 'slug', repeat: true, optional: false }` * - `[[foo]]` -> `{ key: 'foo', repeat: false, optional: true }` * - `[bar]` -> `{ key: 'bar', repeat: false, optional: false }` * - `fizz` -> `{ key: 'fizz', repeat: false, optional: false }` * @param param - The parameter to parse. * @returns The parsed parameter as a data structure. */ export function parseParameter(param) { const match = param.match(PARAMETER_PATTERN); if (!match) { return parseMatchedParameter(param); } return parseMatchedParameter(match[2]); } /** * Parses a matched parameter from the PARAMETER_PATTERN regex to a data structure that can be used * to generate the parametrized route. * Examples: * - `[...slug]` -> `{ key: 'slug', repeat: true, optional: true }` * - `...slug` -> `{ key: 'slug', repeat: true, optional: false }` * - `[foo]` -> `{ key: 'foo', repeat: false, optional: true }` * - `bar` -> `{ key: 'bar', repeat: false, optional: false }` * @param param - The matched parameter to parse. * @returns The parsed parameter as a data structure. */ export function parseMatchedParameter(param) { const optional = param.startsWith('[') && param.endsWith(']'); if (optional) { param = param.slice(1, -1); } const repeat = param.startsWith('...'); if (repeat) { param = param.slice(3); } return { key: param, repeat, optional }; } //# sourceMappingURL=get-dynamic-param.js.map