Skip to content

Commit

Permalink
fix(query): leave object as is
Browse files Browse the repository at this point in the history
Fix #3282
  • Loading branch information
posva committed Aug 7, 2020
1 parent 4fbaa9f commit 7b3328d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
const res = {}
Expand Down
5 changes: 5 additions & 0 deletions test/unit/specs/query.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'] })
Expand Down

0 comments on commit 7b3328d

Please sign in to comment.