Skip to content

Commit 3bbc1a5

Browse files
authored
fix(node): Strip query and fragment from request URLs without route parameters (#8213)
Fix transaction names having query params or fragments attached when request URLs without any route parameters were encountered under [certain conditions](#8213 (comment)), Fixes #6586
1 parent 252c9e9 commit 3bbc1a5

File tree

1 file changed

+8
-2
lines changed
  • packages/tracing-internal/src/node/integrations

1 file changed

+8
-2
lines changed

packages/tracing-internal/src/node/integrations/express.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/* eslint-disable max-lines */
22
import type { Hub, Integration, PolymorphicRequest, Transaction } from '@sentry/types';
3-
import { extractPathForTransaction, getNumberOfUrlSegments, isRegExp, logger } from '@sentry/utils';
3+
import {
4+
extractPathForTransaction,
5+
getNumberOfUrlSegments,
6+
isRegExp,
7+
logger,
8+
stripUrlQueryAndFragment,
9+
} from '@sentry/utils';
410

511
import { shouldDisableAutoInstrumentation } from './utils/node-utils';
612

@@ -335,7 +341,7 @@ function instrumentRouter(appOrRouter: ExpressRouter): void {
335341
if (urlLength === routeLength) {
336342
if (!req._hasParameters) {
337343
if (req._reconstructedRoute !== req.originalUrl) {
338-
req._reconstructedRoute = req.originalUrl;
344+
req._reconstructedRoute = req.originalUrl ? stripUrlQueryAndFragment(req.originalUrl) : req.originalUrl;
339345
}
340346
}
341347

0 commit comments

Comments
 (0)