Skip to content

Commit

Permalink
searcParams missing from urls (#33861)
Browse files Browse the repository at this point in the history
- Fix issue where params such as api-key are not added to the url
  • Loading branch information
jstramel authored Nov 4, 2021
1 parent 2a9ee7c commit c9a35ed
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/gatsby-source-drupal/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ async function worker([url, options]) {
}
}

if (typeof options.searchParams === `object`) {
url = new URL(url)
const searchParams = new URLSearchParams(options.searchParams)
const searchKeys = Array.from(searchParams.keys())
searchKeys.forEach(searchKey => {
// Only add search params to url if it has not already been
// added.
if (!url.searchParams.has(searchKey)) {
url.searchParams.set(searchKey, searchParams.get(searchKey))
}
})
url = url.toString()
}
delete options.searchParams

const response = await got(url, {
agent,
cache: false,
Expand Down Expand Up @@ -467,6 +482,7 @@ ${JSON.stringify(webhookBody, null, 4)}`
username: basicAuth.username,
password: basicAuth.password,
headers,
searchParams: params,
responseType: `json`,
parentSpan: fullFetchSpan,
},
Expand Down

0 comments on commit c9a35ed

Please sign in to comment.