Skip to content

Commit 07a91cc

Browse files
jstewmonsindresorhus
authored andcommittedJul 23, 2018
fix: formatted query should be assigned to options.search (#519)
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.
1 parent 58c12de commit 07a91cc

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
],
3636
"dependencies": {
3737
"@sindresorhus/is": "^0.9.0",
38-
"cacheable-request": "^2.1.1",
38+
"cacheable-request": "^4.0.1",
3939
"decompress-response": "^3.3.0",
4040
"duplexer3": "^0.1.4",
4141
"extend": "^3.0.1",

‎test/arguments.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,21 @@ test('requestUrl with url.parse object as first argument', async t => {
6060
});
6161

6262
test('overrides querystring from opts', async t => {
63-
t.is((await got(`${s.url}/?test=doge`, {query: {test: 'wow'}})).body, '/?test=wow');
63+
const response = await got(
64+
`${s.url}/?drop=this`,
65+
{
66+
query: {test: 'wow'},
67+
cache: {
68+
get(key) {
69+
t.is(key, `cacheable-request:GET:${s.url}/?test=wow`);
70+
},
71+
set(key) {
72+
t.is(key, `cacheable-request:GET:${s.url}/?test=wow`);
73+
}
74+
}
75+
}
76+
);
77+
t.is(response.body, '/?test=wow');
6478
});
6579

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

0 commit comments

Comments
 (0)
Please sign in to comment.