@tanstack/router-core 1.130.10 → 1.130.11
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 +8 -3
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +8 -3
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +21 -3
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -3212,18 +3212,36 @@ export type ProcessRouteTreeResult<TRouteLike extends RouteLike> = {
|
|
|
3212
3212
|
const REQUIRED_PARAM_BASE_SCORE = 0.5
|
|
3213
3213
|
const OPTIONAL_PARAM_BASE_SCORE = 0.4
|
|
3214
3214
|
const WILDCARD_PARAM_BASE_SCORE = 0.25
|
|
3215
|
+
const BOTH_PRESENCE_BASE_SCORE = 0.05
|
|
3216
|
+
const PREFIX_PRESENCE_BASE_SCORE = 0.02
|
|
3217
|
+
const SUFFIX_PRESENCE_BASE_SCORE = 0.01
|
|
3218
|
+
const PREFIX_LENGTH_SCORE_MULTIPLIER = 0.0002
|
|
3219
|
+
const SUFFIX_LENGTH_SCORE_MULTIPLIER = 0.0001
|
|
3215
3220
|
|
|
3216
3221
|
function handleParam(segment: Segment, baseScore: number) {
|
|
3217
3222
|
if (segment.prefixSegment && segment.suffixSegment) {
|
|
3218
|
-
return
|
|
3223
|
+
return (
|
|
3224
|
+
baseScore +
|
|
3225
|
+
BOTH_PRESENCE_BASE_SCORE +
|
|
3226
|
+
PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length +
|
|
3227
|
+
SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length
|
|
3228
|
+
)
|
|
3219
3229
|
}
|
|
3220
3230
|
|
|
3221
3231
|
if (segment.prefixSegment) {
|
|
3222
|
-
return
|
|
3232
|
+
return (
|
|
3233
|
+
baseScore +
|
|
3234
|
+
PREFIX_PRESENCE_BASE_SCORE +
|
|
3235
|
+
PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length
|
|
3236
|
+
)
|
|
3223
3237
|
}
|
|
3224
3238
|
|
|
3225
3239
|
if (segment.suffixSegment) {
|
|
3226
|
-
return
|
|
3240
|
+
return (
|
|
3241
|
+
baseScore +
|
|
3242
|
+
SUFFIX_PRESENCE_BASE_SCORE +
|
|
3243
|
+
SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length
|
|
3244
|
+
)
|
|
3227
3245
|
}
|
|
3228
3246
|
|
|
3229
3247
|
return baseScore
|