@typed/router 0.17.5 → 0.17.7

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@typed/router",
3
- "version": "0.17.5",
3
+ "version": "0.17.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -22,15 +22,15 @@
22
22
  "@effect/data": "^0.17.1",
23
23
  "@effect/io": "^0.38.0",
24
24
  "@typed/context": "0.17.1",
25
- "@typed/dom": "8.17.1",
25
+ "@typed/dom": "8.17.2",
26
26
  "@typed/error": "0.16.1",
27
27
  "@typed/fx": "1.16.1",
28
- "@typed/html": "3.17.4",
29
- "@typed/navigation": "0.4.1",
30
- "@typed/path": "0.6.1",
31
- "@typed/route": "0.13.1"
28
+ "@typed/html": "3.17.6",
29
+ "@typed/navigation": "0.4.2",
30
+ "@typed/path": "0.6.2",
31
+ "@typed/route": "0.13.2"
32
32
  },
33
- "gitHead": "cd3a198eaae31cd7b8b55509e9c959ad1ed1685b",
33
+ "gitHead": "9083c6af485d129f95e5f7b07d1bfb285668b7dd",
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
package/src/Redirect.ts CHANGED
@@ -11,11 +11,17 @@ export class Redirect extends E.tagged('@typed/router/Redirect') {
11
11
  super(`Redirect to ${url}`)
12
12
  }
13
13
 
14
- static redirect(url: string, options?: NavigateOptions): Effect.Effect<never, Redirect, never> {
14
+ static redirect(
15
+ url: string,
16
+ options: NavigateOptions = { history: 'replace' },
17
+ ): Effect.Effect<never, Redirect, never> {
15
18
  return Effect.fail(new Redirect(url, options))
16
19
  }
17
20
 
18
- static redirectFx(url: string, options?: NavigateOptions): Fx.Fx<never, Redirect, never> {
21
+ static redirectFx(
22
+ url: string,
23
+ options: NavigateOptions = { history: 'replace' },
24
+ ): Fx.Fx<never, Redirect, never> {
19
25
  return Fx.fail(new Redirect(url, options))
20
26
  }
21
27
  }
@@ -47,7 +47,8 @@ export function matchRoutes<
47
47
  ) as RENDERABLE
48
48
 
49
49
  return [
50
- nestedRouter.route,
50
+ // If the route is the a single slash, use the route directly to keep any parsing options.
51
+ match.route.path === '/' ? match.route : nestedRouter.route,
51
52
  render,
52
53
  match.options?.guard as
53
54
  | ((params: ParamsOf<string>) => Effect.Effect<_R, NavigationError, boolean>)
@@ -105,11 +106,12 @@ export function matchRoutes<
105
106
  return pipe(
106
107
  matched,
107
108
  isBrowser ? identity : Fx.take(1),
108
- Redirect.switchMatch(
109
- (r) => Fx.as(Fx.fromEffect(router.navigation.navigate(r.url, r.options)), Option.none()),
110
- Fx.map(Option.some),
109
+ Fx.switchLatest,
110
+ Redirect.switchCatch((redirect) =>
111
+ Fx.fromFxEffect(
112
+ Effect.map(router.navigation.navigate(redirect.url, redirect.options), () => Fx.never()),
113
+ ),
111
114
  ),
112
- Fx.compact,
113
115
  )
114
116
  })
115
117
  }