Skip to content

Commit fedde44

Browse files
committed
fix(express) strip query and fragment from tracing URLs (getsentry#6586)
1 parent b9a9390 commit fedde44

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

@@ -343,7 +349,7 @@ function instrumentRouter(appOrRouter: ExpressRouter): void {
343349
if (transaction && transaction.metadata.source !== 'custom') {
344350
// If the request URL is '/' or empty, the reconstructed route will be empty.
345351
// Therefore, we fall back to setting the final route to '/' in this case.
346-
const finalRoute = req._reconstructedRoute || '/';
352+
const finalRoute = stripUrlQueryAndFragment(req._reconstructedRoute || '/');
347353

348354
transaction.setName(...extractPathForTransaction(req, { path: true, method: true, customRoute: finalRoute }));
349355
}

0 commit comments

Comments
 (0)