Skip to content

Commit cb2e99e

Browse files
mydeaLuca Forstner
andcommitted
Apply suggestions from code review
Co-authored-by: Luca Forstner <[email protected]>
1 parent a3279c9 commit cb2e99e

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

packages/node/src/integrations/http/SentryHttpInstrumentation.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -428,21 +428,15 @@ function patchRequestToCaptureBody(req: IncomingMessage, normalizedRequest: Requ
428428
}
429429

430430
function extractQueryParams(req: IncomingMessage): string | undefined {
431-
// url (including path and query string):
432-
let originalUrl = req.url || '';
433-
434-
if (!originalUrl) {
431+
// req.url is path and query string
432+
if (!req.url) {
435433
return;
436434
}
437435

438-
// The `URL` constructor can't handle internal URLs of the form `/some/path/here`, so stick a dummy protocol and
439-
// hostname on the beginning. Since the point here is just to grab the query string, it doesn't matter what we use.
440-
if (originalUrl.startsWith('/')) {
441-
originalUrl = `http://dogs.are.great${originalUrl}`;
442-
}
443-
444436
try {
445-
const queryParams = new URL(originalUrl).search.slice(1);
437+
// The `URL` constructor can't handle internal URLs of the form `/some/path/here`, so stick a dummy protocol and
438+
// hostname as the base. Since the point here is just to grab the query string, it doesn't matter what we use.
439+
const queryParams = new URL(req.url, 'http://dogs.are.great').search.slice(1);
446440
return queryParams.length ? queryParams : undefined;
447441
} catch {
448442
return undefined;

0 commit comments

Comments
 (0)