diff --git a/src/util/query.js b/src/util/query.js index c56cfcad5..fef509a44 100644 --- a/src/util/query.js +++ b/src/util/query.js @@ -38,7 +38,7 @@ export function resolveQuery ( return parsedQuery } -const castQueryParamValue = value => (value == null ? value : String(value)) +const castQueryParamValue = value => (value == null || typeof value === 'object' ? value : String(value)) function parseQuery (query: string): Dictionary { const res = {} diff --git a/test/unit/specs/query.spec.js b/test/unit/specs/query.spec.js index 9c73debe4..54bfcff55 100644 --- a/test/unit/specs/query.spec.js +++ b/test/unit/specs/query.spec.js @@ -25,6 +25,11 @@ describe('Query utils', () => { expect(query).toEqual({ a: undefined, b: null }) }) + it('should keep objects query values', () => { + const query = resolveQuery('', { a: { nested: 'o' }, b: [{ a: true }] }) + expect(query).toEqual({ a: { nested: 'o' }, b: [{ a: true }] }) + }) + it('should keep null query values in arrays', () => { const query = resolveQuery('', { baz: [null, '2'] }) expect(query).toEqual({ baz: [null, '2'] })