Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
31aad1d
refactor(router-core): Process routeTree into segment tree instead of…
Sheraff Nov 1, 2025
df389c6
foo
Sheraff Nov 1, 2025
23bacf4
bar
Sheraff Nov 1, 2025
f3236f2
PoC works
Sheraff Nov 1, 2025
627e017
faster
Sheraff Nov 1, 2025
dd1e3e3
faster
Sheraff Nov 1, 2025
e274212
remove node key, each object is a node
Sheraff Nov 2, 2025
baa2764
handle optional and wildcard
Sheraff Nov 2, 2025
bb4f022
there can be multiple wildcard children on a node because of prefix/s…
Sheraff Nov 2, 2025
adbcdd5
use index for skipping instead of the node itself
Sheraff Nov 2, 2025
8c886b8
fix node collision by param name only
Sheraff Nov 2, 2025
5b784fd
fix init of routesById and routesByPath
Sheraff Nov 2, 2025
9bf39da
some early tests
Sheraff Nov 2, 2025
484fc81
just comments
Sheraff Nov 2, 2025
e2339cc
use bitmask instead of array for skipped nodes during match
Sheraff Nov 2, 2025
f190778
start replacing in path.ts
Sheraff Nov 2, 2025
d6db54e
minor
Sheraff Nov 2, 2025
a60faa8
depth
Sheraff Nov 9, 2025
d15c9d9
fuzzy matching
Sheraff Nov 9, 2025
1a6a969
better sort function
Sheraff Nov 10, 2025
7c91a68
dynamic and optional matches use the stack
Sheraff Nov 10, 2025
4cd8726
no regex during matching yields 2x perf
Sheraff Nov 10, 2025
48f59ce
simplify interpolatePath and matchId
Sheraff Nov 10, 2025
c034ec2
Merge branch 'main' into refactor-router-core-process-route-tree-into…
Sheraff Nov 11, 2025
3fd5fd1
clean resolvePath
Sheraff Nov 11, 2025
54c14b9
optimize parseSegment
Sheraff Nov 11, 2025
4413339
support processing flat route tree for route masks matching
Sheraff Nov 11, 2025
82ae4d4
support routeMasks option as a flat tree
Sheraff Nov 11, 2025
ff17ea8
deprecate MatchRouteOptions 'caseSensitive' option
Sheraff Nov 11, 2025
88cd231
support deprecated single route match, slight performance penalty, st…
Sheraff Nov 11, 2025
56808aa
plug it into actual router
Sheraff Nov 11, 2025
14007cb
remove ai context
Sheraff Nov 11, 2025
a6f379c
ci: apply automated fixes
autofix-ci[bot] Nov 11, 2025
eb140cd
fix build
Sheraff Nov 11, 2025
162a3d7
ci: apply automated fixes
autofix-ci[bot] Nov 11, 2025
58baf3e
typos
Sheraff Nov 11, 2025
4dab29f
fix plugin HMR
Sheraff Nov 11, 2025
66a38b2
remove flatRoutes from devtools
Sheraff Nov 11, 2025
b40c320
wildcard suffix can include slashes
Sheraff Nov 11, 2025
3c10a6c
explore all branches before returning
Sheraff Nov 11, 2025
d20010e
some unit tests
Sheraff Nov 11, 2025
ba4cc90
hmr plugin prettify
Sheraff Nov 11, 2025
5f6236c
init route before processing
Sheraff Nov 11, 2025
3751534
more unit
Sheraff Nov 11, 2025
9f60967
remove commented out
Sheraff Nov 11, 2025
caa7fe1
_splat and *
Sheraff Nov 11, 2025
dfa98e9
prettier
Sheraff Nov 11, 2025
e518239
fix single match and flat match
Sheraff Nov 11, 2025
b8c1c2e
misc optims
Sheraff Nov 11, 2025
7e2ef5d
prettier
Sheraff Nov 11, 2025
58775f7
cache resolvePath
Sheraff Nov 11, 2025
bde9344
resolvePath: improve cache hit rate, add common path skips
Sheraff Nov 11, 2025
89bf3be
restore some matching tests
Sheraff Nov 12, 2025
cd9f4dc
restore some more tests
Sheraff Nov 12, 2025
8110b6e
update unit tests to new segment format (not a fix)
Sheraff Nov 12, 2025
92093b8
some segment parsing fixes
Sheraff Nov 12, 2025
f1a0b7d
fix curly-braced required param without prefix/suffix
Sheraff Nov 12, 2025
2c5d4b1
skipped params are not included at all in the params object
Sheraff Nov 12, 2025
f04d540
fix multi-segment wildcard suffix
Sheraff Nov 12, 2025
b8aead3
add failing match test
Sheraff Nov 12, 2025
3e26bcd
skipped optional nodes can match beyond the end of the path
Sheraff Nov 12, 2025
5c7e8c1
add failing case sensitivity test
Sheraff Nov 12, 2025
c6daad9
Merge branch 'main' into refactor-router-core-process-route-tree-into…
Sheraff Nov 12, 2025
bd59a1e
remove 2nd while loop, everything through the stack, bye bye performance
Sheraff Nov 12, 2025
cd8bd06
add cache to matching methods
Sheraff Nov 12, 2025
9f92e6b
fix build
Sheraff Nov 12, 2025
f3e5a80
fix fuzzy rest argument leading slash
Sheraff Nov 12, 2025
4b2df33
add more test cases
Sheraff Nov 12, 2025
0ca25b1
batch push in stack (will refactor, but at least this works)
Sheraff Nov 12, 2025
4647f9d
remove batch stack append, iterate backwards instead
Sheraff Nov 12, 2025
e9489e1
comments
Sheraff Nov 12, 2025
a46ce08
some more unit tests
Sheraff Nov 12, 2025
947b47e
add comment about skipped bitmask being limited to 32
Sheraff Nov 12, 2025
3785a2e
match wildcards beyond last segment
Sheraff Nov 12, 2025
435f4e9
remove deprecated test file
Sheraff Nov 12, 2025
c2342ef
Merge branch 'main' into refactor-router-core-process-route-tree-into…
Sheraff Nov 12, 2025
20c5b1f
wip test
Sheraff Nov 12, 2025
aafbcd3
include caseSensitivity in dynamic node sort function
Sheraff Nov 13, 2025
320cdbd
more unit tests
Sheraff Nov 13, 2025
896956e
code comment
Sheraff Nov 13, 2025
a30e03d
segments without text cannot be case-sensitive
Sheraff Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The `MatchRouteOptions` type is used to describe the options that can be used wh
```tsx
interface MatchRouteOptions {
pending?: boolean
caseSensitive?: boolean
caseSensitive?: boolean /* @deprecated */
includeSearch?: boolean
fuzzy?: boolean
}
Expand All @@ -24,11 +24,12 @@ The `MatchRouteOptions` type has the following properties:
- Optional
- If `true`, will match against pending location instead of the current location

### `caseSensitive` property
### ~~`caseSensitive`~~ property (deprecated)

- Type: `boolean`
- Optional
- If `true`, will match against the current location with case sensitivity
- Declare case sensitivity in the route definition instead, or globally for all routes using the `caseSensitive` option on the router

### `includeSearch` property

Expand Down
4 changes: 0 additions & 4 deletions packages/react-router/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ export {
trimPathRight,
trimPath,
resolvePath,
parsePathname,
interpolatePath,
matchPathname,
matchByPath,
rootRouteId,
defaultSerializeError,
defaultParseSearch,
Expand All @@ -37,7 +34,6 @@ export type {
RemoveTrailingSlashes,
RemoveLeadingSlashes,
ActiveOptions,
Segment,
ResolveRelativePath,
RootRouteId,
AnyPathParams,
Expand Down
5 changes: 1 addition & 4 deletions packages/react-router/src/useBlocker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ export function useBlocker(
location: HistoryLocation,
): AnyShouldBlockFnLocation {
const parsedLocation = router.parseLocation(location)
const matchedRoutes = router.getMatchedRoutes(
parsedLocation.pathname,
undefined,
)
const matchedRoutes = router.getMatchedRoutes(parsedLocation.pathname)
if (matchedRoutes.foundRoute === undefined) {
throw new Error(`No route found for location ${location.href}`)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/router-core/src/Matches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ export interface MatchRouteOptions {
* If `true`, will match against the current location with case sensitivity.
*
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)
*
* @deprecated Declare case sensitivity in the route definition instead, or globally for all routes using the `caseSensitive` option on the router.
*/
caseSensitive?: boolean
/**
Expand Down
6 changes: 0 additions & 6 deletions packages/router-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,8 @@ export {
removeTrailingSlash,
exactPathTest,
resolvePath,
parsePathname,
interpolatePath,
matchPathname,
matchByPath,
} from './path'
export type { Segment } from './path'
export { encode, decode } from './qss'
export { rootRouteId } from './root'
export type { RootRouteId } from './root'
Expand Down Expand Up @@ -193,8 +189,6 @@ export type {
RootRoute,
FilebaseRouteOptionsInterface,
} from './route'
export { processRouteTree } from './process-route-tree'
export type { ProcessRouteTreeResult } from './process-route-tree'
export {
defaultSerializeError,
getLocationChangeInfo,
Expand Down
6 changes: 6 additions & 0 deletions packages/router-core/src/lru-cache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type LRUCache<TKey, TValue> = {
get: (key: TKey) => TValue | undefined
set: (key: TKey, value: TValue) => void
clear: () => void
}

export function createLRUCache<TKey, TValue>(
Expand Down Expand Up @@ -64,5 +65,10 @@ export function createLRUCache<TKey, TValue>(
cache.set(key, entry)
}
},
clear() {
cache.clear()
oldest = undefined
newest = undefined
},
}
}
Loading
Loading