Skip to content

Commit

Permalink
fix(gatsby-source-drupal): searcParams missing from urls (#33861) (#3…
Browse files Browse the repository at this point in the history
…4018)

- Fix issue where params such as api-key are not added to the url

(cherry picked from commit c9a35ed)

Co-authored-by: Joe Stramel <jstramel@users.noreply.github.com>
  • Loading branch information
GatsbyJS Bot and jstramel committed Nov 18, 2021
1 parent f74cc8f commit 76deb39
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/gatsby-source-drupal/src/gatsby-node.js
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 76deb39

Please sign in to comment.