Skip to content

Commit 3cf6797

Browse files
committed
use new browser-based URL parser
1 parent d31c5f9 commit 3cf6797

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ const _ = require(`lodash`)
33
const urlJoin = require(`url-join`)
44
import HttpAgent from "agentkeepalive"
55
// const http2wrapper = require(`http2-wrapper`)
6-
const url = require(`url`)
7-
const querystring = require(`querystring`)
86

97
const { HttpsAgent } = HttpAgent
108

@@ -391,21 +389,13 @@ exports.sourceNodes = async (
391389
`queueing ${requestsCount} API requests for type ${d.body.data[0].type} which has ${d.body.meta.count} entities.`
392390
)
393391
if (d.body.links.next?.href) {
394-
const parsedUrl = url.parse(d.body.links.next?.href)
395-
const parsedQueryString = querystring.parse(parsedUrl.query)
396392
await Promise.all(
397393
_.range(requestsCount).map(pageOffset => {
398394
pageOffset += 1
399-
// Construct query string.
400-
const newQuerystring = {
401-
...parsedQueryString,
402-
"page[offset]": pageOffset * 50,
403-
}
404-
const newUrl = url.format({
405-
...parsedUrl,
406-
search: querystring.stringify(newQuerystring),
407-
})
408-
return getNext(newUrl)
395+
// Construct URL with new pageOffset.
396+
const newUrl = new URL(d.body.links.next.href)
397+
newUrl.searchParams.set(`page[offset]`, pageOffset * 50)
398+
return getNext(newUrl.toString())
409399
})
410400
)
411401
}

0 commit comments

Comments
 (0)