Skip to content

Commit af822e4

Browse files
committed
fix: avoid passing leading ? to parseQuery
Fix #2571
1 parent 04a621c commit af822e4

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

packages/router/__tests__/location.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('parseURL', () => {
248248
const parseQuery = vi.fn()
249249
originalParseURL(parseQuery, '/?é=é&é=a')
250250
expect(parseQuery).toHaveBeenCalledTimes(1)
251-
expect(parseQuery).toHaveBeenCalledWith('?é=é&é=a')
251+
expect(parseQuery).toHaveBeenCalledWith('é=é&é=a')
252252
})
253253
})
254254

packages/router/__tests__/router.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ describe('Router', () => {
175175
const parseQuery = vi.fn(_ => ({}))
176176
const { router } = await newRouter({ parseQuery })
177177
const to = router.resolve('/foo?bar=baz')
178-
expect(parseQuery).toHaveBeenCalledWith('?bar=baz')
178+
expect(parseQuery).toHaveBeenCalledWith('bar=baz')
179179
expect(to.query).toEqual({})
180180
})
181181

packages/router/src/location.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ export function parseURL(
6868
hashPos > 0 ? hashPos : location.length
6969
)
7070

71-
query = parseQuery(searchString)
71+
query = parseQuery(
72+
// remove the leading ?
73+
searchString.slice(1)
74+
)
7275
}
7376

7477
if (hashPos >= 0) {

0 commit comments

Comments
 (0)