Skip to content

Commit d525412

Browse files
committed
fix(pages): route parsing
1 parent 9aa13f6 commit d525412

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

packages/devtools/client/components/RoutePathItem.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,27 @@ const parts = computed(() => {
1616
return _
1717
})
1818
19-
const path = computed(() => parts.value.map((i, idx) => i[0] === ':' ? partsInput.value[idx] : i).join('').replace(/\/+/g, '/'))
19+
function parseExpressRoute(route: string) {
20+
return route
21+
.split(/(:\w+[\?\*]?(?:\(\))?)/)
22+
.filter(Boolean)
23+
.map(i =>
24+
i[0] === ':'
25+
? i.replace(/\(\)$/, '?')
26+
: i,
27+
)
28+
}
29+
30+
const path = computed(() => parts.value
31+
.map(
32+
(i, idx) =>
33+
i[0] === ':'
34+
? partsInput.value[idx]
35+
: i,
36+
)
37+
.join('')
38+
.replace(/\/+/g, '/'),
39+
)
2040
const hasWildcard = computed(() => props.route.path.includes(':'))
2141
2242
function navigate() {

packages/devtools/client/composables/utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ export function parseReadablePath(path: string, root: string) {
6565
}
6666
}
6767

68-
export function parseExpressRoute(route: string) {
69-
return route.split(/(:\w+[\?\*]?)/).filter(Boolean)
70-
}
71-
7268
export function useAsyncState<T>(key: string, fn: () => Promise<T>, options?: AsyncDataOptions<T>) {
7369
const nuxt = useNuxtApp()
7470
if (!nuxt.payload.unique)

0 commit comments

Comments
 (0)