Skip to content

Commit

Permalink
fix(utils): Try catch new URL when extracting query params (#9675)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad authored Nov 28, 2023
1 parent f97020f commit 28450ad
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/utils/src/requestdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,17 @@ function extractQueryParams(
originalUrl = `http://dogs.are.great${originalUrl}`;
}

return (
req.query ||
(typeof URL !== undefined && new URL(originalUrl).search.replace('?', '')) ||
// In Node 8, `URL` isn't in the global scope, so we have to use the built-in module from Node
(deps && deps.url && deps.url.parse(originalUrl).query) ||
undefined
);
try {
return (
req.query ||
(typeof URL !== undefined && new URL(originalUrl).search.slice(1)) ||
// In Node 8, `URL` isn't in the global scope, so we have to use the built-in module from Node
(deps && deps.url && deps.url.parse(originalUrl).query) ||
undefined
);
} catch {
return undefined;
}
}

/**
Expand Down

0 comments on commit 28450ad

Please sign in to comment.