8000 fix(utils): Try catch new URL when extracting query params (#9675) · Mause/sentry-javascript@28450ad · GitHub
[go: up one dir, main page]

Skip to content

Commit 28450ad

Browse files
authored
fix(utils): Try catch new URL when extracting query params (getsentry#9675)
1 parent f97020f commit 28450ad

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/utils/src/requestdata.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,17 @@ function extractQueryParams(
357357
originalUrl = `http://dogs.are.great${originalUrl}`;
358358
}
359359

360-
return (
361-
req.query ||
362-
(typeof URL !== undefined && new URL(originalUrl).search.replace('?', '')) ||
363-
// In Node 8, `URL` isn't in the global scope, so we have to use the built-in module from Node
364-
(deps && deps.url && deps.url.parse(originalUrl).query) ||
365-
undefined
366-
);
360+
try {
361+
return (
362+
req.query ||
363+
(typeof URL !== undefined && new URL(originalUrl).search.slice(1)) ||
364+
// In Node 8, `URL` isn't in the global scope, so we have to use the built-in module from Node
365+
(deps && deps.url && deps.url.parse(originalUrl).query) ||
366+
undefined
367+
);
368+
} catch {
369+
return undefined;
370+
}
367371
}
368372

369373
/**

0 commit comments

Comments
 (0)
0