@tanstack/react-router 1.143.2 → 1.143.4

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.
@@ -55,7 +55,7 @@ function Transitioner() {
55
55
  state: true,
56
56
  _includeValidateSearch: true
57
57
  });
58
- if (routerCore.trimPathRight(router.latestLocation.href) !== routerCore.trimPathRight(nextLocation.href)) {
58
+ if (routerCore.trimPathRight(router.latestLocation.publicHref) !== routerCore.trimPathRight(nextLocation.publicHref)) {
59
59
  router.commitLocation({ ...nextLocation, replace: true });
60
60
  }
61
61
  return () => {
@@ -1 +1 @@
1
- {"version":3,"file":"Transitioner.cjs","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as React from 'react'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useLayoutEffect, usePrevious } from './utils'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\n\nexport function Transitioner() {\n const router = useRouter()\n const mountLoadForRouter = React.useRef({ router, mounted: false })\n\n const [isTransitioning, setIsTransitioning] = React.useState(false)\n // Track pending state changes\n const { hasPendingMatches, isLoading } = useRouterState({\n select: (s) => ({\n isLoading: s.isLoading,\n hasPendingMatches: s.matches.some((d) => d.status === 'pending'),\n }),\n structuralSharing: true,\n })\n\n const previousIsLoading = usePrevious(isLoading)\n\n const isAnyPending = isLoading || isTransitioning || hasPendingMatches\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n const isPagePending = isLoading || hasPendingMatches\n const previousIsPagePending = usePrevious(isPagePending)\n\n router.startTransition = (fn: () => void) => {\n setIsTransitioning(true)\n React.startTransition(() => {\n fn()\n setIsTransitioning(false)\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n React.useEffect(() => {\n const unsub = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n if (\n trimPathRight(router.latestLocation.href) !==\n trimPathRight(nextLocation.href)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n }, [router, router.history])\n\n // Try to load the initial location\n useLayoutEffect(() => {\n if (\n // if we are hydrating from SSR, loading is triggered in ssr-client\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.current.router === router &&\n mountLoadForRouter.current.mounted)\n ) {\n return\n }\n mountLoadForRouter.current = { router, mounted: true }\n\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n\n tryLoad()\n }, [router])\n\n useLayoutEffect(() => {\n // The router was loading and now it's not\n if (previousIsLoading && !isLoading) {\n router.emit({\n type: 'onLoad', // When the new URL has committed, when the new matches have been loaded into state.matches\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [previousIsLoading, router, isLoading])\n\n useLayoutEffect(() => {\n // emit onBeforeRouteMount\n if (previousIsPagePending && !isPagePending) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [isPagePending, previousIsPagePending, router])\n\n useLayoutEffect(() => {\n if (previousIsAnyPending && !isAnyPending) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s: typeof router.state) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n }, [isAnyPending, previousIsAnyPending, router])\n\n return null\n}\n"],"names":["useRouter","React","useRouterState","usePrevious","trimPathRight","useLayoutEffect","getLocationChangeInfo","handleHashScroll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAAS,eAAe;AAC7B,QAAM,SAASA,UAAAA,UAAA;AACf,QAAM,qBAAqBC,iBAAM,OAAO,EAAE,QAAQ,SAAS,OAAO;AAElE,QAAM,CAAC,iBAAiB,kBAAkB,IAAIA,iBAAM,SAA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AEhD,UAAM,UAAU,YAAY;AAC1B,UAAI;AACF,cAAM,OAAO,KAAA;AAAA,MACf,SAAS,KAAK;AACZ,gBAAQ,MAAM,GAAG;AAAA,MACnB;AAAA,IACF;AAEA,YAAA;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AAEXA,QAAAA,gBAAgB,MAAM;AAEpB,QAAI,qBAAqB,CAAC,WAAW;AACnC,aAAO,KAAK;AAAA,QACV,MAAM;AAAA;AAAA,QACN,GAAGC,WAAAA,sBAAsB,OAAO,KAAK;AAAA,MAAA,CACtC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,mBAAmB,QAAQ,SAAS,CAAC;AAEzCD,QAAAA,gBAAgB,MAAM;AAEpB,QAAI,yBAAyB,CAAC,eAAe;AAC3C,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,GAAGC,WAAAA,sBAAsB,OAAO,KAAK;AAAA,MAAA,CACtC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,eAAe,uBAAuB,MAAM,CAAC;AAEjDD,QAAAA,gBAAgB,MAAM;AACpB,QAAI,wBAAwB,CAAC,cAAc;AACzC,YAAM,aAAaC,WAAAA,sBAAsB,OAAO,KAAK;AACrD,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MAAA,CACJ;AAED,aAAO,QAAQ,SAAS,CAAC,OAA4B;AAAA,QACnD,GAAG;AAAA,QACH,QAAQ;AAAA,QACR,kBAAkB,EAAE;AAAA,MAAA,EACpB;AAEF,UAAI,WAAW,aAAa;AAC1BC,mBAAAA,iBAAiB,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,cAAc,sBAAsB,MAAM,CAAC;AAE/C,SAAO;AACT;;"}
1
+ {"version":3,"file":"Transitioner.cjs","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as React from 'react'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useLayoutEffect, usePrevious } from './utils'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\n\nexport function Transitioner() {\n const router = useRouter()\n const mountLoadForRouter = React.useRef({ router, mounted: false })\n\n const [isTransitioning, setIsTransitioning] = React.useState(false)\n // Track pending state changes\n const { hasPendingMatches, isLoading } = useRouterState({\n select: (s) => ({\n isLoading: s.isLoading,\n hasPendingMatches: s.matches.some((d) => d.status === 'pending'),\n }),\n structuralSharing: true,\n })\n\n const previousIsLoading = usePrevious(isLoading)\n\n const isAnyPending = isLoading || isTransitioning || hasPendingMatches\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n const isPagePending = isLoading || hasPendingMatches\n const previousIsPagePending = usePrevious(isPagePending)\n\n router.startTransition = (fn: () => void) => {\n setIsTransitioning(true)\n React.startTransition(() => {\n fn()\n setIsTransitioning(false)\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n React.useEffect(() => {\n const unsub = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) for consistency with\n // the server-side redirect check in router.beforeLoad.\n if (\n trimPathRight(router.latestLocation.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n }, [router, router.history])\n\n // Try to load the initial location\n useLayoutEffect(() => {\n if (\n // if we are hydrating from SSR, loading is triggered in ssr-client\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.current.router === router &&\n mountLoadForRouter.current.mounted)\n ) {\n return\n }\n mountLoadForRouter.current = { router, mounted: true }\n\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n\n tryLoad()\n }, [router])\n\n useLayoutEffect(() => {\n // The router was loading and now it's not\n if (previousIsLoading && !isLoading) {\n router.emit({\n type: 'onLoad', // When the new URL has committed, when the new matches have been loaded into state.matches\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [previousIsLoading, router, isLoading])\n\n useLayoutEffect(() => {\n // emit onBeforeRouteMount\n if (previousIsPagePending && !isPagePending) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [isPagePending, previousIsPagePending, router])\n\n useLayoutEffect(() => {\n if (previousIsAnyPending && !isAnyPending) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s: typeof router.state) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n }, [isAnyPending, previousIsAnyPending, router])\n\n return null\n}\n"],"names":["useRouter","React","useRouterState","usePrevious","trimPathRight","useLayoutEffect","getLocationChangeInfo","handleHashScroll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAUO,SAAS,eAAe;AAC7B,QAAM,SAASA,UAAAA,UAAA;AACf,QAAM,qBAAqBC,iBAAM,OAAO,EAAE,QAAQ,SAAS,OAAO;AAElE,QAAM,CAAC,iBAAiB,kBAAkB,IAAIA,iBAAM,SAAS,KAAK;AAElE,QAAM,EAAE,mBAAmB,UAAA,IAAcC,8BAAe;AAAA,IACtD,QAAQ,CAAC,OAAO;AAAA,MACd,WAAW,EAAE;AAAA,MACb,mBAAmB,EAAE,QAAQ,KAAK,CAAC,MAAM,EAAE,WAAW,SAAS;AAAA,IAAA;AAAA,IAEjE,mBAAmB;AAAA,EAAA,CACpB;AAED,QAAM,oBAAoBC,MAAAA,YAAY,SAAS;AAE/C,QAAM,eAAe,aAAa,mBAAmB;AACrD,QAAM,uBAAuBA,MAAAA,YAAY,YAAY;AAErD,QAAM,gBAAgB,aAAa;AACnC,QAAM,wBAAwBA,MAAAA,YAAY,aAAa;AAEvD,SAAO,kBAAkB,CAAC,OAAmB;AAC3C,u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AAyB,CAAC,eAAe;AAC3C,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,GAAGC,WAAAA,sBAAsB,OAAO,KAAK;AAAA,MAAA,CACtC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,eAAe,uBAAuB,MAAM,CAAC;AAEjDD,QAAAA,gBAAgB,MAAM;AACpB,QAAI,wBAAwB,CAAC,cAAc;AACzC,YAAM,aAAaC,WAAAA,sBAAsB,OAAO,KAAK;AACrD,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MAAA,CACJ;AAED,aAAO,QAAQ,SAAS,CAAC,OAA4B;AAAA,QACnD,GAAG;AAAA,QACH,QAAQ;AAAA,QACR,kBAAkB,EAAE;AAAA,MAAA,EACpB;AAEF,UAAI,WAAW,aAAa;AAC1BC,mBAAAA,iBAAiB,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,cAAc,sBAAsB,MAAM,CAAC;AAE/C,SAAO;AACT;;"}
@@ -36,7 +36,7 @@ function Transitioner() {
36
36
  state: true,
37
37
  _includeValidateSearch: true
38
38
  });
39
- if (trimPathRight(router.latestLocation.href) !== trimPathRight(nextLocation.href)) {
39
+ if (trimPathRight(router.latestLocation.publicHref) !== trimPathRight(nextLocation.publicHref)) {
40
40
  router.commitLocation({ ...nextLocation, replace: true });
41
41
  }
42
42
  return () => {
@@ -1 +1 @@
1
- {"version":3,"file":"Transitioner.js","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as React from 'react'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useLayoutEffect, usePrevious } from './utils'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\n\nexport function Transitioner() {\n const router = useRouter()\n const mountLoadForRouter = React.useRef({ router, mounted: false })\n\n const [isTransitioning, setIsTransitioning] = React.useState(false)\n // Track pending state changes\n const { hasPendingMatches, isLoading } = useRouterState({\n select: (s) => ({\n isLoading: s.isLoading,\n hasPendingMatches: s.matches.some((d) => d.status === 'pending'),\n }),\n structuralSharing: true,\n })\n\n const previousIsLoading = usePrevious(isLoading)\n\n const isAnyPending = isLoading || isTransitioning || hasPendingMatches\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n const isPagePending = isLoading || hasPendingMatches\n const previousIsPagePending = usePrevious(isPagePending)\n\n router.startTransition = (fn: () => void) => {\n setIsTransitioning(true)\n React.startTransition(() => {\n fn()\n setIsTransitioning(false)\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n React.useEffect(() => {\n const unsub = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n if (\n trimPathRight(router.latestLocation.href) !==\n trimPathRight(nextLocation.href)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n }, [router, router.history])\n\n // Try to load the initial location\n useLayoutEffect(() => {\n if (\n // if we are hydrating from SSR, loading is triggered in ssr-client\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.current.router === router &&\n mountLoadForRouter.current.mounted)\n ) {\n return\n }\n mountLoadForRouter.current = { router, mounted: true }\n\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n\n tryLoad()\n }, [router])\n\n useLayoutEffect(() => {\n // The router was loading and now it's not\n if (previousIsLoading && !isLoading) {\n router.emit({\n type: 'onLoad', // When the new URL has committed, when the new matches have been loaded into state.matches\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [previousIsLoading, router, isLoading])\n\n useLayoutEffect(() => {\n // emit onBeforeRouteMount\n if (previousIsPagePending && !isPagePending) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [isPagePending, previousIsPagePending, router])\n\n useLayoutEffect(() => {\n if (previousIsAnyPending && !isAnyPending) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s: typeof router.state) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n }, [isAnyPending, previousIsAnyPending, router])\n\n return null\n}\n"],"names":[],"mappings":";;;;;AAUO,SAAS,eAAe;AAC7B,QAAM,SAAS,UAAA;AACf,QAAM,qBAAqB,MAAM,OAAO,EAAE,QAAQ,SAAS,OAAO;AAElE,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,MAAM,SAAS,KAAK;AAElE,QAAM,EAAE,mBAAmB,UAAA,IAAc,eAAe;AAAA,IACtD,QAAQ,CAAC,OAAO;AAAA,MACd,WAAW,EAAE;AAAA,MACb,mBAAmB,EAAE,QAAQ,KAAK,CAAC,MAAM,EAAE,WAAW,SAAS;AAAA,IAAA;AAAA,IAEjE,mBAAmB;AAAA,EAAA,CACpB;AAED,QAAM,oBAAoB,YAAY,SAAS;AAE/C,QAAM,eAAe,aAAa,mBAAmB;AACrD,QAAM,uBAAuB,YAAY,YAAY;AAErD,QAAM,gBAAgB,aAAa;AACnC,QAAM,wBAAwB,YAAY,aAAa;AAEvD,SAAO,kBAAkB,CAAC,OAAmB;AAC3C,uBAAmB,IAAI;AACvB,UAAM,gBAAgB,MAAM;AAC1B,SAAA;AACA,yBAAmB,KAAK;AAAA,IAC1B,CAAC;AAAA,EACH;AAIA,QAAM,UAAU,MAAM;AACpB,UAAM,QAAQ,OAAO,QAAQ,UAAU,OAAO,IAAI;AAElD,UAAM,eAAe,OAAO,cAAc;AAAA,MACxC,IAAI,OAAO,eAAe;AAAA,MAC1B,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,wBAAwB;AAAA,IAAA,CACzB;AAED,QACE,cAAc,OAAO,eAAe,IAAI,MACxC,cAAc,aAAa,IAAI,GAC/B;AACA,aA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Aa;AAC1B,yBAAiB,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,cAAc,sBAAsB,MAAM,CAAC;AAE/C,SAAO;AACT;"}
1
+ {"version":3,"file":"Transitioner.js","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as React from 'react'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useLayoutEffect, usePrevious } from './utils'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\n\nexport function Transitioner() {\n const router = useRouter()\n const mountLoadForRouter = React.useRef({ router, mounted: false })\n\n const [isTransitioning, setIsTransitioning] = React.useState(false)\n // Track pending state changes\n const { hasPendingMatches, isLoading } = useRouterState({\n select: (s) => ({\n isLoading: s.isLoading,\n hasPendingMatches: s.matches.some((d) => d.status === 'pending'),\n }),\n structuralSharing: true,\n })\n\n const previousIsLoading = usePrevious(isLoading)\n\n const isAnyPending = isLoading || isTransitioning || hasPendingMatches\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n const isPagePending = isLoading || hasPendingMatches\n const previousIsPagePending = usePrevious(isPagePending)\n\n router.startTransition = (fn: () => void) => {\n setIsTransitioning(true)\n React.startTransition(() => {\n fn()\n setIsTransitioning(false)\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n React.useEffect(() => {\n const unsub = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) for consistency with\n // the server-side redirect check in router.beforeLoad.\n if (\n trimPathRight(router.latestLocation.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n }, [router, router.history])\n\n // Try to load the initial location\n useLayoutEffect(() => {\n if (\n // if we are hydrating from SSR, loading is triggered in ssr-client\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.current.router === router &&\n mountLoadForRouter.current.mounted)\n ) {\n return\n }\n mountLoadForRouter.current = { router, mounted: true }\n\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n\n tryLoad()\n }, [router])\n\n useLayoutEffect(() => {\n // The router was loading and now it's not\n if (previousIsLoading && !isLoading) {\n router.emit({\n type: 'onLoad', // When the new URL has committed, when the new matches have been loaded into state.matches\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [previousIsLoading, router, isLoading])\n\n useLayoutEffect(() => {\n // emit onBeforeRouteMount\n if (previousIsPagePending && !isPagePending) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n }, [isPagePending, previousIsPagePending, router])\n\n useLayoutEffect(() => {\n if (previousIsAnyPending && !isAnyPending) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s: typeof router.state) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n }, [isAnyPending, previousIsAnyPending, router])\n\n return null\n}\n"],"names":[],"mappings":";;;;;AAUO,SAAS,eAAe;AAC7B,QAAM,SAAS,UAAA;AACf,QAAM,qBAAqB,MAAM,OAAO,EAAE,QAAQ,SAAS,OAAO;AAElE,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,MAAM,SAAS,KAAK;AAElE,QAAM,EAAE,mBAAmB,UAAA,IAAc,eAAe;AAAA,IACtD,QAAQ,CAAC,OAAO;AAAA,MACd,WAAW,EAAE;AAAA,MACb,mBAAmB,EAAE,QAAQ,KAAK,CAAC,MAAM,EAAE,WAAW,SAAS;AAAA,IAAA;AAAA,IAEjE,mBAAmB;AAAA,EAAA,CACpB;AAED,QAAM,oBAAoB,YAAY,SAAS;AAE/C,QAAM,eAAe,aAAa,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,IACH;AAAA,EACF,GAAG,CAAC,mBAAmB,QAAQ,SAAS,CAAC;AAEzC,kBAAgB,MAAM;AAEpB,QAAI,yBAAyB,CAAC,eAAe;AAC3C,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,GAAG,sBAAsB,OAAO,KAAK;AAAA,MAAA,CACtC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,eAAe,uBAAuB,MAAM,CAAC;AAEjD,kBAAgB,MAAM;AACpB,QAAI,wBAAwB,CAAC,cAAc;AACzC,YAAM,aAAa,sBAAsB,OAAO,KAAK;AACrD,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MAAA,CACJ;AAED,aAAO,QAAQ,SAAS,CAAC,OAA4B;AAAA,QACnD,GAAG;AAAA,QACH,QAAQ;AAAA,QACR,kBAAkB,EAAE;AAAA,MAAA,EACpB;AAEF,UAAI,WAAW,aAAa;AAC1B,yBAAiB,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,cAAc,sBAAsB,MAAM,CAAC;AAE/C,SAAO;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.143.2",
3
+ "version": "1.143.4",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -79,8 +79,8 @@
79
79
  "isbot": "^5.1.22",
80
80
  "tiny-invariant": "^1.3.3",
81
81
  "tiny-warning": "^1.0.3",
82
- "@tanstack/history": "1.141.0",
83
- "@tanstack/router-core": "1.142.13"
82
+ "@tanstack/router-core": "1.143.4",
83
+ "@tanstack/history": "1.141.0"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@testing-library/jest-dom": "^6.6.3",
@@ -52,9 +52,12 @@ export function Transitioner() {
52
52
  _includeValidateSearch: true,
53
53
  })
54
54
 
55
+ // Check if the current URL matches the canonical form.
56
+ // Compare publicHref (browser-facing URL) for consistency with
57
+ // the server-side redirect check in router.beforeLoad.
55
58
  if (
56
- trimPathRight(router.latestLocation.href) !==
57
- trimPathRight(nextLocation.href)
59
+ trimPathRight(router.latestLocation.publicHref) !==
60
+ trimPathRight(nextLocation.publicHref)
58
61
  ) {
59
62
  router.commitLocation({ ...nextLocation, replace: true })
60
63
  }