Skip to content

Commit 15a2833

Browse files
committed
fix: Encode query URI parameters
1 parent 4489ca8 commit 15a2833

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/create-http-client.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import version from '../version'
2+
import qs from 'qs'
23

34
/**
45
* Create pre configured axios instance
@@ -29,6 +30,7 @@ export default function createHttpClient (axios, {space, accessToken, insecure,
2930
return axios.create({
3031
baseURL: `${insecure ? 'http' : 'https'}://${hostname}:${port}/spaces/${space}/`,
3132
headers: headers,
32-
agent: agent
33+
agent: agent,
34+
paramsSerializer: qs.stringify
3335
})
3436
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"babel-runtime": "^6.3.19",
5151
"follow-redirects": "0.0.7",
5252
"json-stringify-safe": "^5.0.1",
53-
"lodash": "^4.2.0"
53+
"lodash": "^4.2.0",
54+
"qs": "^6.1.0"
5455
},
5556
"devDependencies": {
5657
"axios": "^0.9.1",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import test from 'tape'
2+
3+
import createRequestConfig from '../../lib/create-request-config'
4+
5+
test('Create request config', t => {
6+
const config = createRequestConfig({
7+
resolveLinks: true,
8+
query: {}
9+
})
10+
11+
t.ok(config.params, 'params property exist')
12+
t.notOk(config.params.resolveLinks, 'resolveLinks property is removed from query')
13+
t.end()
14+
})

0 commit comments

Comments
 (0)