@tanstack/react-router 1.5.6 → 1.5.8

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.
@@ -9,7 +9,7 @@ import { HistoryState } from '@tanstack/history';
9
9
  export type CleanPath<T extends string> = T extends `${infer L}//${infer R}` ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`> : T extends `${infer L}//` ? `${CleanPath<L>}/` : T extends `//${infer L}` ? `/${CleanPath<L>}` : T;
10
10
  export type Split<S, TIncludeTrailingSlash = true> = S extends unknown ? string extends S ? string[] : S extends string ? CleanPath<S> extends '' ? [] : TIncludeTrailingSlash extends true ? CleanPath<S> extends `${infer T}/` ? [...Split<T>, '/'] : CleanPath<S> extends `/${infer U}` ? Split<U> : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : [S] : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : S extends string ? [S] : never : never : never;
11
11
  export type ParsePathParams<T extends string> = keyof {
12
- [K in Trim<Split<T>[number], '_'> as K extends `$${infer L}` ? L : never]: K;
12
+ [K in Trim<Split<T>[number], '_'> as K extends `$${infer L}` ? L extends '' ? '_splat' : L : never]: K;
13
13
  };
14
14
  export type Join<T, Delimiter extends string = '/'> = T extends [] ? '' : T extends [infer L extends string] ? L : T extends [infer L extends string, ...infer Tail extends [...string[]]] ? CleanPath<`${L}${Delimiter}${Join<Tail>}`> : never;
15
15
  export type Last<T extends any[]> = T extends [...infer _, infer L] ? L : never;
@@ -2482,7 +2482,8 @@
2482
2482
  };
2483
2483
  buildLocation = opts => {
2484
2484
  const build = (dest = {}, matches) => {
2485
- const fromSearch = (this.state.pendingMatches || this.state.matches).reverse()[0]?.search || this.latestLocation.search;
2485
+ const relevantMatches = this.state.pendingMatches || this.state.matches;
2486
+ const fromSearch = relevantMatches[relevantMatches.length - 1]?.search || this.latestLocation.search;
2486
2487
  let pathname = this.resolvePathWithBase(dest.from ?? this.latestLocation.pathname, `${dest.to ?? ''}`);
2487
2488
  const fromMatches = this.matchRoutes(this.latestLocation.pathname, fromSearch);
2488
2489
  const stayingMatches = matches?.filter(d => fromMatches?.find(e => e.routeId === d.routeId));