From 3cf6797487dbb98ac91667e8e35a6205dd42c05f Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 23 Aug 2021 13:32:06 -0700 Subject: [PATCH] use new browser-based URL parser --- .../gatsby-source-drupal/src/gatsby-node.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/gatsby-source-drupal/src/gatsby-node.js b/packages/gatsby-source-drupal/src/gatsby-node.js index 9aebd21bd4772..ee012ae5bb119 100644 --- a/packages/gatsby-source-drupal/src/gatsby-node.js +++ b/packages/gatsby-source-drupal/src/gatsby-node.js @@ -3,8 +3,6 @@ const _ = require(`lodash`) const urlJoin = require(`url-join`) import HttpAgent from "agentkeepalive" // const http2wrapper = require(`http2-wrapper`) -const url = require(`url`) -const querystring = require(`querystring`) const { HttpsAgent } = HttpAgent @@ -391,21 +389,13 @@ exports.sourceNodes = async ( `queueing ${requestsCount} API requests for type ${d.body.data[0].type} which has ${d.body.meta.count} entities.` ) if (d.body.links.next?.href) { - const parsedUrl = url.parse(d.body.links.next?.href) - const parsedQueryString = querystring.parse(parsedUrl.query) await Promise.all( _.range(requestsCount).map(pageOffset => { pageOffset += 1 - // Construct query string. - const newQuerystring = { - ...parsedQueryString, - "page[offset]": pageOffset * 50, - } - const newUrl = url.format({ - ...parsedUrl, - search: querystring.stringify(newQuerystring), - }) - return getNext(newUrl) + // Construct URL with new pageOffset. + const newUrl = new URL(d.body.links.next.href) + newUrl.searchParams.set(`page[offset]`, pageOffset * 50) + return getNext(newUrl.toString()) }) ) }