@tanstack/react-router 1.75.0 → 1.76.3

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/react-router",
3
- "version": "1.75.0",
3
+ "version": "1.76.3",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/link.tsx CHANGED
@@ -874,8 +874,8 @@ export function useLinkProps<
874
874
  }
875
875
  }
876
876
 
877
- type UseLinkReactProps<TComp> = TComp extends keyof JSX.IntrinsicElements
878
- ? JSX.IntrinsicElements[TComp]
877
+ type UseLinkReactProps<TComp> = TComp extends keyof React.JSX.IntrinsicElements
878
+ ? React.JSX.IntrinsicElements[TComp]
879
879
  : React.PropsWithoutRef<
880
880
  TComp extends React.ComponentType<infer TProps> ? TProps : never
881
881
  > &
package/src/path.ts CHANGED
@@ -87,6 +87,7 @@ interface ResolvePathOptions {
87
87
  base: string
88
88
  to: string
89
89
  trailingSlash?: 'always' | 'never' | 'preserve'
90
+ caseSensitive?: boolean
90
91
  }
91
92
 
92
93
  export function resolvePath({
@@ -94,9 +95,10 @@ export function resolvePath({
94
95
  base,
95
96
  to,
96
97
  trailingSlash = 'never',
98
+ caseSensitive,
97
99
  }: ResolvePathOptions) {
98
- base = removeBasepath(basepath, base)
99
- to = removeBasepath(basepath, to)
100
+ base = removeBasepath(basepath, base, caseSensitive)
101
+ to = removeBasepath(basepath, to, caseSensitive)
100
102
 
101
103
  let baseSegments = parsePathname(base)
102
104
  const toSegments = parsePathname(to)
@@ -260,15 +262,23 @@ export function matchPathname(
260
262
  return pathParams ?? {}
261
263
  }
262
264
 
263
- export function removeBasepath(basepath: string, pathname: string) {
265
+ export function removeBasepath(
266
+ basepath: string,
267
+ pathname: string,
268
+ caseSensitive: boolean = false,
269
+ ) {
270
+ // normalize basepath and pathname for case-insensitive comparison if needed
271
+ const normalizedBasepath = caseSensitive ? basepath : basepath.toLowerCase()
272
+ const normalizedPathname = caseSensitive ? pathname : pathname.toLowerCase()
273
+
264
274
  switch (true) {
265
275
  // default behaviour is to serve app from the root - pathname
266
276
  // left untouched
267
- case basepath === '/':
277
+ case normalizedBasepath === '/':
268
278
  return pathname
269
279
 
270
- // shortcut for removing the basepath from the equal pathname
271
- case pathname === basepath:
280
+ // shortcut for removing the basepath if it matches the pathname
281
+ case normalizedPathname === normalizedBasepath:
272
282
  return ''
273
283
 
274
284
  // in case pathname is shorter than basepath - there is
@@ -280,11 +290,11 @@ export function removeBasepath(basepath: string, pathname: string) {
280
290
  // earlier, otherwise, basepath separated from pathname with
281
291
  // separator, therefore lack of separator means partial
282
292
  // segment match (`/app` should not match `/application`)
283
- case pathname[basepath.length] !== '/':
293
+ case normalizedPathname[normalizedBasepath.length] !== '/':
284
294
  return pathname
285
295
 
286
- // remove the basepath from the pathname in case there is any
287
- case pathname.startsWith(basepath):
296
+ // remove the basepath from the pathname if it starts with it
297
+ case normalizedPathname.startsWith(normalizedBasepath):
288
298
  return pathname.slice(basepath.length)
289
299
 
290
300
  // otherwise, return the pathname as is
@@ -303,9 +313,13 @@ export function matchByPath(
303
313
  return undefined
304
314
  }
305
315
  // Remove the base path from the pathname
306
- from = removeBasepath(basepath, from)
316
+ from = removeBasepath(basepath, from, matchLocation.caseSensitive)
307
317
  // Default to to $ (wildcard)
308
- const to = removeBasepath(basepath, `${matchLocation.to ?? '$'}`)
318
+ const to = removeBasepath(
319
+ basepath,
320
+ `${matchLocation.to ?? '$'}`,
321
+ matchLocation.caseSensitive,
322
+ )
309
323
 
310
324
  // Parse the from and to
311
325
  const baseSegments = parsePathname(from)
package/src/router.ts CHANGED
@@ -722,6 +722,7 @@ export class Router<
722
722
  defaultPendingMinMs: 500,
723
723
  context: undefined!,
724
724
  ...options,
725
+ caseSensitive: options.caseSensitive ?? false,
725
726
  notFoundMode: options.notFoundMode ?? 'fuzzy',
726
727
  stringifySearch: options.stringifySearch ?? defaultStringifySearch,
727
728
  parseSearch: options.parseSearch ?? defaultParseSearch,
@@ -1007,6 +1008,7 @@ export class Router<
1007
1008
  base: from,
1008
1009
  to: cleanPath(path),
1009
1010
  trailingSlash: this.options.trailingSlash,
1011
+ caseSensitive: this.options.caseSensitive,
1010
1012
  })
1011
1013
  return resolvedPath
1012
1014
  }