Skip to content

Commit 7b3328d

Browse files
committed
fix(query): leave object as is
Fix #3282
1 parent 4fbaa9f commit 7b3328d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/util/query.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function resolveQuery (
3838
return parsedQuery
3939
}
4040

41-
const castQueryParamValue = value => (value == null ? value : String(value))
41+
const castQueryParamValue = value => (value == null || typeof value === 'object' ? value : String(value))
4242

4343
function parseQuery (query: string): Dictionary<string> {
4444
const res = {}

test/unit/specs/query.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ describe('Query utils', () => {
2525
expect(query).toEqual({ a: undefined, b: null })
2626
})
2727

28+
it('should keep objects query values', () => {
29+
const query = resolveQuery('', { a: { nested: 'o' }, b: [{ a: true }] })
30+
expect(query).toEqual({ a: { nested: 'o' }, b: [{ a: true }] })
31+
})
32+
2833
it('should keep null query values in arrays', () => {
2934
const query = resolveQuery('', { baz: [null, '2'] })
3035
expect(query).toEqual({ baz: [null, '2'] })

0 commit comments

Comments
 (0)