@tanstack/router-core 0.0.1-beta.52 → 0.0.1-beta.53

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.52",
4
+ "version": "0.0.1-beta.53",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
package/src/history.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  // This implementation attempts to be more lightweight by
3
3
  // making assumptions about the way TanStack Router works
4
4
 
5
+ import { match } from 'assert'
6
+
5
7
  export interface RouterHistory {
6
8
  location: RouterLocation
7
9
  listen: (cb: () => void) => () => void
@@ -177,11 +179,19 @@ export function createMemoryHistory(
177
179
  function parseLocation(href: string, state: any): RouterLocation {
178
180
  let hashIndex = href.indexOf('#')
179
181
  let searchIndex = href.indexOf('?')
180
- const pathEnd = Math.min(hashIndex, searchIndex)
181
182
 
182
183
  return {
183
184
  href,
184
- pathname: pathEnd > -1 ? href.substring(0, pathEnd) : href,
185
+ pathname: href.substring(
186
+ 0,
187
+ hashIndex > 0
188
+ ? searchIndex > 0
189
+ ? Math.min(hashIndex, searchIndex)
190
+ : hashIndex
191
+ : searchIndex > 0
192
+ ? searchIndex
193
+ : href.length,
194
+ ),
185
195
  hash: hashIndex > -1 ? href.substring(hashIndex, searchIndex) : '',
186
196
  search: searchIndex > -1 ? href.substring(searchIndex) : '',
187
197
  state,
package/src/router.ts CHANGED
@@ -820,7 +820,12 @@ export class Router<
820
820
  }
821
821
  }
822
822
 
823
- invalidateRoute = async (opts: MatchLocation) => {
823
+ invalidateRoute = async <
824
+ TFrom extends ValidFromPath<TAllRouteInfo> = '/',
825
+ TTo extends string = '.',
826
+ >(
827
+ opts: ToOptions<TAllRouteInfo, TFrom, TTo>,
828
+ ) => {
824
829
  const next = this.buildNext(opts)
825
830
  const unloadedMatchIds = this.matchRoutes(next.pathname).map((d) => d.id)
826
831
 
@@ -1010,7 +1015,7 @@ export class Router<
1010
1015
  ) {
1011
1016
  e.preventDefault()
1012
1017
  if (pathIsEqual && !search && !hash) {
1013
- this.invalidateRoute(nextOpts)
1018
+ this.invalidateRoute(nextOpts as any)
1014
1019
  }
1015
1020
 
1016
1021
  // All is well? Navigate!