Skip to content

Commit 757c81d

Browse files
Fixes a bug related to filters appended onto next links for gatsby-source-drupal. (#31350)
1 parent 54aaca4 commit 757c81d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,17 @@ exports.sourceNodes = async (
249249
// See https://www.drupal.org/docs/8/modules/jsonapi/filtering
250250
if (typeof filters === `object`) {
251251
if (filters.hasOwnProperty(type)) {
252-
url = url + `?${filters[type]}`
252+
url = new URL(url)
253+
const filterParams = new URLSearchParams(filters[type])
254+
const filterKeys = Array.from(filterParams.keys())
255+
filterKeys.forEach(filterKey => {
256+
// Only add filter params to url if it has not already been
257+
// added.
258+
if (!url.searchParams.has(filterKey)) {
259+
url.searchParams.set(filterKey, filterParams.get(filterKey))
260+
}
261+
})
262+
url = url.toString()
253263
}
254264
}
255265
}

0 commit comments

Comments
 (0)