/
opt
/
canhelp
/
node_modules
/
next
/
dist
/
shared
/
lib
/
router
/
utils
/
/opt/canhelp/node_modules/next/dist/shared/lib/router/utils
mkdir
upload
Name
Size
Mode
Actions
add-locale.d.ts
365
0644
edit
dl
rm
add-locale.js
1049
0644
edit
dl
rm
add-locale.js.map
1715
0644
edit
dl
rm
add-path-prefix.d.ts
200
0644
edit
dl
rm
add-path-prefix.js
536
0644
edit
dl
rm
add-path-prefix.js.map
885
0644
edit
dl
rm
add-path-suffix.d.ts
258
0644
edit
dl
rm
add-path-suffix.js
536
0644
edit
dl
rm
add-path-suffix.js.map
944
0644
edit
dl
rm
app-paths.d.ts
900
0644
edit
dl
rm
app-paths.js
1504
0644
edit
dl
rm
app-paths.js.map
2712
0644
edit
dl
rm
as-path-to-search-params.d.ts
79
0644
edit
dl
rm
as-path-to-search-params.js
484
0644
edit
dl
rm
as-path-to-search-params.js.map
565
0644
edit
dl
rm
cache-busting-search-param.d.ts
257
0644
edit
dl
rm
cache-busting-search-param.js
832
0644
edit
dl
rm
cache-busting-search-param.js.map
1315
0644
edit
dl
rm
compare-states.d.ts
146
0644
edit
dl
rm
compare-states.js
1070
0644
edit
dl
rm
compare-states.js.map
1931
0644
edit
dl
rm
disable-smooth-scroll.d.ts
304
0644
edit
dl
rm
disable-smooth-scroll.js
2515
0644
edit
dl
rm
disable-smooth-scroll.js.map
3621
0644
edit
dl
rm
escape-path-delimiters.d.ts
96
0644
edit
dl
rm
escape-path-delimiters.js
508
0644
edit
dl
rm
escape-path-delimiters.js.map
753
0644
edit
dl
rm
format-next-pathname-info.d.ts
261
0644
edit
dl
rm
format-next-pathname-info.js
1290
0644
edit
dl
rm
format-next-pathname-info.js.map
2090
0644
edit
dl
rm
format-url.d.ts
216
0644
edit
dl
rm
format-url.js
3955
0644
edit
dl
rm
format-url.js.map
5739
0644
edit
dl
rm
get-asset-path-from-route.d.ts
84
0644
edit
dl
rm
get-asset-path-from-route.js
639
0644
edit
dl
rm
get-asset-path-from-route.js.map
846
0644
edit
dl
rm
get-dynamic-param.d.ts
2775
0644
edit
dl
rm
get-dynamic-param.js
3976
0644
edit
dl
rm
get-dynamic-param.js.map
7442
0644
edit
dl
rm
get-next-pathname-info.d.ts
1450
0644
edit
dl
rm
get-next-pathname-info.js
2479
0644
edit
dl
rm
get-next-pathname-info.js.map
5178
0644
edit
dl
rm
get-route-from-asset-path.d.ts
88
0644
edit
dl
rm
get-route-from-asset-path.js
931
0644
edit
dl
rm
get-route-from-asset-path.js.map
1324
0644
edit
dl
rm
html-bots.d.ts
53
0644
edit
dl
rm
html-bots.js
1135
0644
edit
dl
rm
html-bots.js.map
1145
0644
edit
dl
rm
index.d.ts
121
0644
edit
dl
rm
index.js
766
0644
edit
dl
rm
index.js.map
430
0644
edit
dl
rm
interception-routes.d.ts
312
0644
edit
dl
rm
interception-routes.js
4354
0644
edit
dl
rm
interception-routes.js.map
5054
0644
edit
dl
rm
interpolate-as.d.ts
195
0644
edit
dl
rm
interpolate-as.js
2242
0644
edit
dl
rm
interpolate-as.js.map
3801
0644
edit
dl
rm
is-bot.d.ts
291
0644
edit
dl
rm
is-bot.js
1764
0644
edit
dl
rm
is-bot.js.map
1998
0644
edit
dl
rm
is-dynamic.d.ts
316
0644
edit
dl
rm
is-dynamic.js
867
0644
edit
dl
rm
is-dynamic.js.map
1489
0644
edit
dl
rm
is-local-url.d.ts
147
0644
edit
dl
rm
is-local-url.js
854
0644
edit
dl
rm
is-local-url.js.map
1271
0644
edit
dl
rm
middleware-route-matcher.d.ts
463
0644
edit
dl
rm
middleware-route-matcher.js
947
0644
edit
dl
rm
middleware-route-matcher.js.map
1762
0644
edit
dl
rm
omit.d.ts
126
0644
edit
dl
rm
omit.js
440
0644
edit
dl
rm
omit.js.map
778
0644
edit
dl
rm
parse-path.d.ts
320
0644
edit
dl
rm
parse-path.js
1041
0644
edit
dl
rm
parse-path.js.map
1510
0644
edit
dl
rm
parse-relative-url.d.ts
745
0644
edit
dl
rm
parse-relative-url.js
1476
0644
edit
dl
rm
parse-relative-url.js.map
3015
0644
edit
dl
rm
parse-url.d.ts
365
0644
edit
dl
rm
parse-url.js
954
0644
edit
dl
rm
parse-url.js.map
1843
0644
edit
dl
rm
path-has-prefix.d.ts
364
0644
edit
dl
rm
path-has-prefix.js
535
0644
edit
dl
rm
path-has-prefix.js.map
996
0644
edit
dl
rm
path-match.d.ts
989
0644
edit
dl
rm
path-match.js
1961
0644
edit
dl
rm
path-match.js.map
3773
0644
edit
dl
rm
prepare-destination.d.ts
1527
0644
edit
dl
rm
prepare-destination.js
10637
0644
edit
dl
rm
prepare-destination.js.map
17187
0644
edit
dl
rm
querystring.d.ts
348
0644
edit
dl
rm
querystring.js
2281
0644
edit
dl
rm
querystring.js.map
3287
0644
edit
dl
rm
relativize-url.d.ts
679
0644
edit
dl
rm
relativize-url.js
1121
0644
edit
dl
rm
relativize-url.js.map
1872
0644
edit
dl
rm
remove-path-prefix.d.ts
389
0644
edit
dl
rm
remove-path-prefix.js
1261
0644
edit
dl
rm
remove-path-prefix.js.map
2000
0644
edit
dl
rm
remove-trailing-slash.d.ts
259
0644
edit
dl
rm
remove-trailing-slash.js
552
0644
edit
dl
rm
remove-trailing-slash.js.map
598
0644
edit
dl
rm
resolve-rewrites.d.ts
682
0644
edit
dl
rm
resolve-rewrites.js
4670
0644
edit
dl
rm
resolve-rewrites.js.map
7781
0644
edit
dl
rm
route-match-utils.d.ts
1513
0644
edit
dl
rm
route-match-utils.js
3675
0644
edit
dl
rm
route-match-utils.js.map
5754
0644
edit
dl
rm
route-matcher.d.ts
384
0644
edit
dl
rm
route-matcher.js
1509
0644
edit
dl
rm
route-matcher.js.map
2558
0644
edit
dl
rm
route-regex.d.ts
3492
0644
edit
dl
rm
route-regex.js
9498
0644
edit
dl
rm
route-regex.js.map
17577
0644
edit
dl
rm
sortable-routes.d.ts
4249
0644
edit
dl
rm
sortable-routes.js
6321
0644
edit
dl
rm
sortable-routes.js.map
12530
0644
edit
dl
rm
sorted-routes.d.ts
344
0644
edit
dl
rm
sorted-routes.js
11664
0644
edit
dl
rm
sorted-routes.js.map
14788
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/next/dist/shared/lib/router/utils/sortable-routes.js
(6321B)
/** * A route that can be sorted by specificity. */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 0 && (module.exports = { compareRouteSegments: null, getSegmentSpecificity: null, sortPageObjects: null, sortPages: null, sortSortableRouteObjects: null, sortSortableRoutes: null }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: all[name] }); } _export(exports, { compareRouteSegments: function() { return compareRouteSegments; }, getSegmentSpecificity: function() { return getSegmentSpecificity; }, sortPageObjects: function() { return sortPageObjects; }, sortPages: function() { return sortPages; }, sortSortableRouteObjects: function() { return sortSortableRouteObjects; }, sortSortableRoutes: function() { return sortSortableRoutes; } }); function getSegmentSpecificity(segment) { // Static segments are most specific - they match exactly one path if (!segment.includes('[')) { return 0; } // Optional catch-all [[...param]] is least specific - matches zero or more segments if (segment.startsWith('[[...') && segment.endsWith(']]')) { return 3; } // Catch-all [...param] is less specific - matches one or more segments if (segment.startsWith('[...') && segment.endsWith(']')) { return 2; } // Regular dynamic [param] is more specific than catch-all - matches exactly one segment if (segment.startsWith('[') && segment.endsWith(']')) { return 1; } // Default to static (fallback case) return 0; } function compareRouteSegments(pathA, pathB) { // Split paths into segments, removing empty strings from leading/trailing slashes const segmentsA = pathA.split('/').filter(Boolean); const segmentsB = pathB.split('/').filter(Boolean); // Compare segment by segment up to the length of the longer path const maxLength = Math.max(segmentsA.length, segmentsB.length); for(let i = 0; i < maxLength; i++){ const segA = segmentsA[i] || ''; const segB = segmentsB[i] || ''; // Handle length differences: shorter routes are MORE specific // Example: "/api" is more specific than "/api/users" if (!segA && segB) return -1 // pathA is shorter, so more specific ; if (segA && !segB) return 1 // pathB is shorter, so more specific ; if (!segA && !segB) return 0 // Both paths ended, they're equal ; // Compare segment specificity using our specificity scoring const specificityA = getSegmentSpecificity(segA); const specificityB = getSegmentSpecificity(segB); // Lower specificity number = more specific route // Example: "api" (0) vs "[slug]" (1) - "api" wins if (specificityA !== specificityB) { return specificityA - specificityB; } // If segments have same specificity, compare lexicographically for determinism // Example: "[id]" vs "[slug]" - "[id]" comes first alphabetically if (segA !== segB) { return segA.localeCompare(segB); } // Segments are identical, continue to next segment } // All segments compared equally return 0; } /** * Compares two complete routes for sorting purposes. * * Routes are compared with a two-tier priority system: * 1. Primary: Compare by source path specificity * 2. Secondary: If sources are equal, compare by page path specificity * * This ensures that routes are primarily organized by their source patterns, * with page-specific variations grouped together. * * @param a - First route to compare * @param b - Second route to compare * @returns Negative if route a should come first, positive if route b should come first, 0 if equal */ function compareSortableRoutes(a, b) { // First compare by source specificity - this is the primary sorting criterion // Source represents the original route pattern and takes precedence const sourceResult = compareRouteSegments(a.sourcePage, b.sourcePage); if (sourceResult !== 0) return sourceResult; // If sources are identical, compare by page specificity as a tiebreaker // Page represents the final rendered route and provides secondary ordering return compareRouteSegments(a.page, b.page); } function sortSortableRoutes(routes) { // Because sort is always in-place, we need to create a shallow copy to avoid // mutating the input array. return [ ...routes ].sort(compareSortableRoutes); } function sortPages(pages) { // Because sort is always in-place, we need to create a shallow copy to avoid // mutating the input array. return [ ...pages ].sort(compareRouteSegments); } function sortSortableRouteObjects(objects, getter) { // Create a SortableRoute for each object. const routes = []; for (const object of objects){ const route = getter(object); routes.push({ ...route, object }); } // In-place sort the SortableRoutes. routes.sort(compareSortableRoutes); // Map the sorted SortableRoutes back to the original objects. return routes.map((param)=>{ let { object } = param; return object; }); } function sortPageObjects(objects, getter) { const indexes = {}; const pages = new Set(); for(let i = 0; i < objects.length; i++){ var _indexes_page; const object = objects[i]; const page = getter(object); ((_indexes_page = indexes[page]) == null ? void 0 : _indexes_page.push(i)) || (indexes[page] = [ i ]); pages.add(page); } // Sort the unique pages. const sortedPages = Array.from(pages).sort(compareRouteSegments); // Map the sorted pages back to the original objects. return sortedPages.reduce((sortedObjects, page)=>{ // Add all objects for this page to the sorted array. for (const i of indexes[page]){ sortedObjects.push(objects[i]); } // Return the sorted array. return sortedObjects; }, []); } //# sourceMappingURL=sortable-routes.js.map
Save
cmd:
run