@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
- "version": "1.130.10",
3
+ "version": "1.130.11",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
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 baseScore + 0.05
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 baseScore + 0.02
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 baseScore + 0.01
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