Skip to content

Commit 73be4bb

Browse files
committed
feat(client): support relative link in resolveRoute and resolveRoutePath
1 parent 62cec2e commit 73be4bb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/client/src/router/resolveRoute.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export interface ResolvedRoute<T extends RouteMeta = RouteMeta>
1313
*/
1414
export const resolveRoute = <T extends RouteMeta = RouteMeta>(
1515
path: string,
16+
current?: string,
1617
): ResolvedRoute<T> => {
17-
const routePath = resolveRoutePath(path)
18+
const routePath = resolveRoutePath(path, current)
1819
const route = routes.value[routePath] ?? {
1920
...routes.value['/404.html'],
2021
notFound: true,

packages/client/src/router/resolveRoutePath.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { redirects, routes } from '../internal/routes.js'
44
/**
55
* Resolve route path with given raw path
66
*/
7-
export const resolveRoutePath = (path: string): string => {
7+
export const resolveRoutePath = (path: string, current?: string): string => {
88
// normalized path
9-
const normalizedPath = normalizeRoutePath(path)
9+
const normalizedPath = normalizeRoutePath(path, current)
1010
if (routes.value[normalizedPath]) return normalizedPath
1111

1212
// encoded path

0 commit comments

Comments
 (0)