Skip to content

Commit

Permalink
searcParams missing from urls (#33861) (#33895)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Stramel <jstramel@users.noreply.github.com>
  • Loading branch information
GatsbyJS Bot and jstramel authored Nov 8, 2021
1 parent e32b355 commit 60de482
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 60de482

Please sign in to comment.