Skip to content

Commit 63e1854

Browse files
chore(deps): bump query-string from 6.14.1 to 7.0.0 (#83)
* chore(deps): bump query-string from 6.14.1 to 7.0.0 Bumps [query-string](https://github.com/sindresorhus/query-string) from 6.14.1 to 7.0.0. - [Release notes](https://github.com/sindresorhus/query-string/releases) - [Commits](sindresorhus/query-string@v6.14.1...v7.0.0) Signed-off-by: dependabot[bot] <[email protected]> * fix: drop empty array values Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Dorian Maliszewski <[email protected]>
1 parent ee2e666 commit 63e1854

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

packages/use-query-params/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"license": "MIT",
2929
"dependencies": {
30-
"query-string": "^6.14.1",
30+
"query-string": "^7.0.0",
3131
"react-router-dom": "^5.2.0"
3232
},
3333
"peerDependencies": {

packages/use-query-params/src/__tests__/index.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { act, renderHook } from '@testing-library/react-hooks'
22
import React from 'react'
3-
import { MemoryRouter } from 'react-router-dom'
4-
import useQueryParam from '../index'
3+
import { MemoryRouter, useHistory } from 'react-router-dom'
4+
import useQueryParam from '..'
55

66
// eslint-disable-next-line react/prop-types
77
const wrapper = ({ pathname = 'one', search }) => ({ children }) => (
@@ -206,4 +206,37 @@ describe('useQueryParam', () => {
206206
compagny: 'Scaleway',
207207
})
208208
})
209+
210+
test('should correctly set query params with array', () => {
211+
jest.useFakeTimers()
212+
const { result, rerender } = renderHook(
213+
() => [useQueryParam(), useHistory()],
214+
{
215+
wrapper: wrapper({ search: '' }),
216+
},
217+
)
218+
219+
act(() => {
220+
result.current[0].setQueryParams({
221+
names: ['John', null, 'Jane', null, undefined, ''],
222+
})
223+
})
224+
jest.runAllTimers()
225+
expect(result.current[0].queryParams).toEqual({
226+
names: ['John', null, 'Jane', null, undefined, ''],
227+
})
228+
expect(result.current[1].location.search).toEqual('?names=John,Jane')
229+
230+
rerender()
231+
})
232+
233+
test('should correctly with existing array', () => {
234+
const { result } = renderHook(() => useQueryParam(), {
235+
wrapper: wrapper({ search: 'names=John,,Jane,,,' }),
236+
})
237+
238+
expect(result.current.queryParams).toEqual({
239+
names: ['John', '', 'Jane', '', '', ''],
240+
})
241+
})
209242
})

packages/use-query-params/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const useQueryParams = () => {
2222
params =>
2323
stringify(params, {
2424
arrayFormat: 'comma',
25+
skipEmptyString: true,
26+
skipNull: true,
2527
sort: (a, b) => a.localeCompare(b),
2628
}),
2729
[],

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7492,10 +7492,10 @@ qs@~6.5.2:
74927492
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
74937493
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
74947494

7495-
query-string@^6.14.1:
7496-
version "6.14.1"
7497-
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.14.1.tgz#7ac2dca46da7f309449ba0f86b1fd28255b0c86a"
7498-
integrity sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==
7495+
query-string@^7.0.0:
7496+
version "7.0.0"
7497+
resolved "https://registry.yarnpkg.com/query-string/-/query-string-7.0.0.tgz#aaad2c8d5c6a6d0c6afada877fecbd56af79e609"
7498+
integrity sha512-Iy7moLybliR5ZgrK/1R3vjrXq03S13Vz4Rbm5Jg3EFq1LUmQppto0qtXz4vqZ386MSRjZgnTSZ9QC+NZOSd/XA==
74997499
dependencies:
75007500
decode-uri-component "^0.2.0"
75017501
filter-obj "^1.1.0"

0 commit comments

Comments
 (0)