Skip to content

Commit 0460409

Browse files
committed
fix: preserve correct search query url
1 parent adc8d07 commit 0460409

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

app/router.options.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { RouterConfig } from 'nuxt/schema'
2+
3+
function stringifyQuery(query: Record<string, any>): string {
4+
const parts: string[] = []
5+
for (const key in query) {
6+
const value = query[key]
7+
if (value == null) continue
8+
if (Array.isArray(value)) {
9+
for (const v of value) {
10+
if (v != null) {
11+
parts.push(
12+
`${encodeURIComponent(key)}=${encodeURIComponent(String(v)).replace(/%40/g, '@').replace(/%2F/gi, '/').replace(/%3A/gi, ':')}`,
13+
)
14+
}
15+
}
16+
} else {
17+
parts.push(
18+
`${encodeURIComponent(key)}=${encodeURIComponent(String(value)).replace(/%40/g, '@').replace(/%2F/gi, '/').replace(/%3A/gi, ':')}`,
19+
)
20+
}
21+
}
22+
return parts.join('&')
23+
}
24+
25+
export default <RouterConfig>{
26+
stringifyQuery,
27+
}

0 commit comments

Comments
 (0)