Skip to content

Commit

Permalink
fix: formatted query should be assigned to options.search (#519)
Browse files Browse the repository at this point in the history
cacheable-request < 4 used url.format to construct the cache key, which
ignored `path` as normalized by got because url.format uses `pathname`
and `search` when formatting the path.
  • Loading branch information
jstewmon authored and sindresorhus committed Jul 23, 2018
1 parent 58c12de commit 07a91cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
],
"dependencies": {
"@sindresorhus/is": "^0.9.0",
"cacheable-request": "^2.1.1",
"cacheable-request": "^4.0.1",
"decompress-response": "^3.3.0",
"duplexer3": "^0.1.4",
"extend": "^3.0.1",
Expand Down
16 changes: 15 additions & 1 deletion test/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,21 @@ test('requestUrl with url.parse object as first argument', async t => {
});

test('overrides querystring from opts', async t => {
t.is((await got(`${s.url}/?test=doge`, {query: {test: 'wow'}})).body, '/?test=wow');
const response = await got(
`${s.url}/?drop=this`,
{
query: {test: 'wow'},
cache: {
get(key) {
t.is(key, `cacheable-request:GET:${s.url}/?test=wow`);
},
set(key) {
t.is(key, `cacheable-request:GET:${s.url}/?test=wow`);
}
}
}
);
t.is(response.body, '/?test=wow');
});

test('should throw with auth in url string', async t => {
Expand Down

0 comments on commit 07a91cc

Please sign in to comment.