/
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/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
Save
cmd:
run