Skip to content

Commit

Permalink
fix(node): Strip query and fragment from request URLs without route p…
Browse files Browse the repository at this point in the history
…arameters (#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
  • Loading branch information
richardsimko committed May 30, 2023
1 parent 252c9e9 commit 3bbc1a5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/tracing-internal/src/node/integrations/express.ts
@@ -1,6 +1,12 @@
/* 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';

Expand Down Expand Up @@ -335,7 +341,7 @@ function instrumentRouter(appOrRouter: ExpressRouter): void {
if (urlLength === routeLength) {
if (!req._hasParameters) {
if (req._reconstructedRoute !== req.originalUrl) {
req._reconstructedRoute = req.originalUrl;
req._reconstructedRoute = req.originalUrl ? stripUrlQueryAndFragment(req.originalUrl) : req.originalUrl;
}
}

Expand Down

0 comments on commit 3bbc1a5

Please sign in to comment.