Skip to content

Commit

Permalink
fix: Encode query URI parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
trodrigues committed Mar 22, 2016
1 parent 4489ca8 commit 15a2833
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/create-http-client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import version from '../version'
import qs from 'qs'

/**
* Create pre configured axios instance
Expand Down Expand Up @@ -29,6 +30,7 @@ export default function createHttpClient (axios, {space, accessToken, insecure,
return axios.create({
baseURL: `${insecure ? 'http' : 'https'}://${hostname}:${port}/spaces/${space}/`,
headers: headers,
agent: agent
agent: agent,
paramsSerializer: qs.stringify
})
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"babel-runtime": "^6.3.19",
"follow-redirects": "0.0.7",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.2.0"
"lodash": "^4.2.0",
"qs": "^6.1.0"
},
"devDependencies": {
"axios": "^0.9.1",
Expand Down
14 changes: 14 additions & 0 deletions test/unit/create-request-config-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from 'tape'

import createRequestConfig from '../../lib/create-request-config'

test('Create request config', t => {
const config = createRequestConfig({
resolveLinks: true,
query: {}
})

t.ok(config.params, 'params property exist')
t.notOk(config.params.resolveLinks, 'resolveLinks property is removed from query')
t.end()
})

0 comments on commit 15a2833

Please sign in to comment.