Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit 35e51dc

Browse files
authored
Merge pull request #411 from netlify/bug/query-param
fix: array query parameters
2 parents 383b805 + cb8f792 commit 35e51dc

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/index.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,20 @@ test('Can use global parameters in query variables', async (t) => {
177177
t.true(scope.isDone())
178178
})
179179

180+
test('Allow array query parameters', async (t) => {
181+
const siteId = uuidv4()
182+
const scope = nock(origin)
183+
.get(
184+
`${pathPrefix}/sites/${siteId}/plugin_runs/latest?packages%5B%5D=%40scope%2Fpackage&packages%5B%5D=%40scope%2Fpackage-two`,
185+
)
186+
.reply(200)
187+
188+
const client = getClient()
189+
await client.getLatestPluginRuns({ site_id: siteId, packages: ['@scope/package', '@scope/package-two'] })
190+
191+
t.true(scope.isDone())
192+
})
193+
180194
test('Can specify JSON request body as an object', async (t) => {
181195
const body = { test: 'test' }
182196
const scope = nock(origin).post(`${pathPrefix}/accounts`, body, { 'Content-Type': 'application/json' }).reply(200)

src/methods/url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const addQueryParams = function (url, parameters, requestParams) {
2626
return url
2727
}
2828

29-
return `${url}?${queryString.stringify(queryParams)}`
29+
return `${url}?${queryString.stringify(queryParams, { arrayFormat: 'brackets' })}`
3030
}
3131

3232
const getRequestParams = function (params, requestParams, name) {

0 commit comments

Comments
 (0)