Skip to content

Commit 688376b

Browse files
jstramelvladar
authored andcommitted
searcParams missing from urls (#33861)
- Fix issue where params such as api-key are not added to the url (cherry picked from commit c9a35ed)
1 parent 476a591 commit 688376b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/gatsby-source-drupal/src/gatsby-node.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ async function worker([url, options]) {
6161
}
6262
}
6363

64+
if (typeof options.searchParams === `object`) {
65+
url = new URL(url)
66+
const searchParams = new URLSearchParams(options.searchParams)
67+
const searchKeys = Array.from(searchParams.keys())
68+
searchKeys.forEach(searchKey => {
69+
// Only add search params to url if it has not already been
70+
// added.
71+
if (!url.searchParams.has(searchKey)) {
72+
url.searchParams.set(searchKey, searchParams.get(searchKey))
73+
}
74+
})
75+
url = url.toString()
76+
}
77+
delete options.searchParams
78+
6479
const response = await got(url, {
6580
agent,
6681
cache: false,
@@ -467,6 +482,7 @@ ${JSON.stringify(webhookBody, null, 4)}`
467482
username: basicAuth.username,
468483
password: basicAuth.password,
469484
headers,
485+
searchParams: params,
470486
responseType: `json`,
471487
parentSpan: fullFetchSpan,
472488
},

0 commit comments

Comments
 (0)