From cab834f9092a1e622f489c624b7b79160471b7d3 Mon Sep 17 00:00:00 2001 From: Richard Simko <1245031+richardsimko@users.noreply.github.com> Date: Thu, 25 May 2023 09:39:32 +0200 Subject: [PATCH] fix(express) strip query and fragment from tracing URLs (#6586) --- packages/tracing-internal/src/node/integrations/express.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/tracing-internal/src/node/integrations/express.ts b/packages/tracing-internal/src/node/integrations/express.ts index 8b3bcb52fcf4..169b3fc743f3 100644 --- a/packages/tracing-internal/src/node/integrations/express.ts +++ b/packages/tracing-internal/src/node/integrations/express.ts @@ -1,6 +1,6 @@ /* eslint-disable max-lines */ import type { Hub, Integration, PolymorphicRequest, Transaction } from '@sentry/types'; -import { extractPathForTransaction, getNumberOfUrlSegments, isRegExp, logger } from '@sentry/utils'; +import { extractPathForTransaction, getNumberOfUrlSegments, isRegExp, logger, stripUrlQueryAndFragment } from '@sentry/utils'; import { shouldDisableAutoInstrumentation } from './utils/node-utils'; @@ -343,7 +343,7 @@ function instrumentRouter(appOrRouter: ExpressRouter): void { if (transaction && transaction.metadata.source !== 'custom') { // If the request URL is '/' or empty, the reconstructed route will be empty. // Therefore, we fall back to setting the final route to '/' in this case. - const finalRoute = req._reconstructedRoute || '/'; + const finalRoute = stripUrlQueryAndFragment(req._reconstructedRoute) || '/'; transaction.setName(...extractPathForTransaction(req, { path: true, method: true, customRoute: finalRoute })); }