@tanstack/router-core 1.139.1 → 1.139.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/src/router.ts CHANGED
@@ -1974,7 +1974,7 @@ export class RouterCore<
1974
1974
  *
1975
1975
  * @link https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType
1976
1976
  */
1977
- navigate: NavigateFn = ({ to, reloadDocument, href, ...rest }) => {
1977
+ navigate: NavigateFn = async ({ to, reloadDocument, href, ...rest }) => {
1978
1978
  if (!reloadDocument && href) {
1979
1979
  try {
1980
1980
  new URL(`${href}`)
@@ -1987,6 +1987,26 @@ export class RouterCore<
1987
1987
  const location = this.buildLocation({ to, ...rest } as any)
1988
1988
  href = location.url
1989
1989
  }
1990
+
1991
+ // Check blockers for external URLs unless ignoreBlocker is true
1992
+ if (!rest.ignoreBlocker) {
1993
+ // Cast to access internal getBlockers method
1994
+ const historyWithBlockers = this.history as any
1995
+ const blockers = historyWithBlockers.getBlockers?.() ?? []
1996
+ for (const blocker of blockers) {
1997
+ if (blocker?.blockerFn) {
1998
+ const shouldBlock = await blocker.blockerFn({
1999
+ currentLocation: this.latestLocation,
2000
+ nextLocation: this.latestLocation, // External URLs don't have a next location in our router
2001
+ action: 'PUSH',
2002
+ })
2003
+ if (shouldBlock) {
2004
+ return Promise.resolve()
2005
+ }
2006
+ }
2007
+ }
2008
+ }
2009
+
1990
2010
  if (rest.replace) {
1991
2011
  window.location.replace(href)
1992
2012
  } else {