Skip to content

Commit cab834f

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

File tree

1 file changed

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

1 file changed

+2
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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 { extractPathForTransaction, getNumberOfUrlSegments, isRegExp, logger, stripUrlQueryAndFragment } from '@sentry/utils';
44

55
import { shouldDisableAutoInstrumentation } from './utils/node-utils';
66

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

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

0 commit comments

Comments
 (0)