@tanstack/router-core 1.136.2 → 1.136.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +1 -0
- package/dist/cjs/ssr/constants.cjs.map +1 -1
- package/dist/cjs/ssr/constants.d.cts +1 -0
- package/dist/cjs/ssr/ssr-client.cjs +2 -0
- package/dist/cjs/ssr/ssr-client.cjs.map +1 -1
- package/dist/cjs/ssr/ssr-client.d.cts +4 -1
- package/dist/cjs/ssr/ssr-server.cjs +64 -12
- package/dist/cjs/ssr/ssr-server.cjs.map +1 -1
- package/dist/cjs/ssr/tsrScript.cjs +1 -1
- package/dist/cjs/ssr/tsrScript.cjs.map +1 -1
- package/dist/cjs/utils.cjs +14 -28
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +1 -1
- package/dist/esm/router.d.ts +1 -0
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/ssr/constants.d.ts +1 -0
- package/dist/esm/ssr/constants.js.map +1 -1
- package/dist/esm/ssr/ssr-client.d.ts +4 -1
- package/dist/esm/ssr/ssr-client.js +2 -0
- package/dist/esm/ssr/ssr-client.js.map +1 -1
- package/dist/esm/ssr/ssr-server.js +64 -12
- package/dist/esm/ssr/ssr-server.js.map +1 -1
- package/dist/esm/ssr/tsrScript.js +1 -1
- package/dist/esm/ssr/tsrScript.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -1
- package/dist/esm/utils.js +14 -28
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +1 -0
- package/src/ssr/constants.ts +1 -0
- package/src/ssr/ssr-client.ts +10 -1
- package/src/ssr/ssr-server.ts +69 -12
- package/src/ssr/tsrScript.ts +4 -0
- package/src/utils.ts +16 -54
package/src/ssr/tsrScript.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -489,50 +489,12 @@ export function findLast<T>(
|
|
|
489
489
|
return undefined
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
-
|
|
493
|
-
'%25', // %
|
|
494
|
-
'%5C', // \
|
|
495
|
-
]
|
|
496
|
-
|
|
497
|
-
function splitAndDecode(
|
|
498
|
-
part: string,
|
|
499
|
-
decodeIgnore: Array<string>,
|
|
500
|
-
startIndex = 0,
|
|
501
|
-
): string {
|
|
502
|
-
// decode the path / path segment by splitting it into parts defined by the ignore list.
|
|
503
|
-
// once these pieces have been decoded, join them back together to form the final decoded path segment with the ignored character in place.
|
|
504
|
-
// we walk through the ignore list linearly, breaking the segment up into pieces and decoding each piece individually.
|
|
505
|
-
// use index traversal to avoid making unnecessary copies of the array.
|
|
506
|
-
for (let i = startIndex; i < decodeIgnore.length; i++) {
|
|
507
|
-
const char = decodeIgnore[i]!.toUpperCase()
|
|
508
|
-
|
|
509
|
-
// check if the part includes the current ignore character
|
|
510
|
-
// if it doesn't continue to the next ignore character
|
|
511
|
-
if (part.includes(char)) {
|
|
512
|
-
// split the part into pieces that needs to be checked and decoded
|
|
513
|
-
const partsToDecode = part.split(char)
|
|
514
|
-
const partsToJoin = new Array<string>(partsToDecode.length)
|
|
515
|
-
|
|
516
|
-
// now check and decode each piece individually taking into consideration the remaining ignored characters.
|
|
517
|
-
// since we are walking through the list linearly, we only need to consider ignore items not yet traversed.
|
|
518
|
-
for (let j = 0; j < partsToDecode.length; j++) {
|
|
519
|
-
const partToDecode = partsToDecode[j]!
|
|
520
|
-
// once we have traversed the entire ignore list, each decoded part is returned.
|
|
521
|
-
partsToJoin[j] = splitAndDecode(partToDecode, decodeIgnore, i + 1)
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// and join them back together to form the final decoded path segment with the ignored character in place.
|
|
525
|
-
return partsToJoin.join(char)
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
// once we have reached the end of the ignore list, we start walking back returning each decoded part.
|
|
530
|
-
// should there be no matching characters, the path segment as a whole will be decoded.
|
|
492
|
+
function decodeSegment(segment: string): string {
|
|
531
493
|
try {
|
|
532
|
-
return decodeURI(
|
|
494
|
+
return decodeURI(segment)
|
|
533
495
|
} catch {
|
|
534
496
|
// if the decoding fails, try to decode the various parts leaving the malformed tags in place
|
|
535
|
-
return
|
|
497
|
+
return segment.replaceAll(/%[0-9A-F]{2}/gi, (match) => {
|
|
536
498
|
try {
|
|
537
499
|
return decodeURI(match)
|
|
538
500
|
} catch {
|
|
@@ -542,17 +504,17 @@ function splitAndDecode(
|
|
|
542
504
|
}
|
|
543
505
|
}
|
|
544
506
|
|
|
545
|
-
export function decodePath(
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
match.
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
return
|
|
507
|
+
export function decodePath(path: string, decodeIgnore?: Array<string>): string {
|
|
508
|
+
if (!path) return path
|
|
509
|
+
const re = decodeIgnore
|
|
510
|
+
? new RegExp(`${decodeIgnore.join('|')}`, 'gi')
|
|
511
|
+
: /%25|%5C/gi
|
|
512
|
+
let cursor = 0
|
|
513
|
+
let result = ''
|
|
514
|
+
let match
|
|
515
|
+
while (null !== (match = re.exec(path))) {
|
|
516
|
+
result += decodeSegment(path.slice(cursor, match.index)) + match[0]
|
|
517
|
+
cursor = re.lastIndex
|
|
518
|
+
}
|
|
519
|
+
return result + decodeSegment(cursor ? path.slice(cursor) : path)
|
|
558
520
|
}
|