File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -150,9 +150,17 @@ function getRouteStringFromRoutes(routes: Route[]): string {
150
150
}
151
151
}
152
152
153
- return routesWithPaths
153
+ const pathParts = routesWithPaths
154
154
. slice ( index )
155
155
. filter ( ( { path } ) => ! ! path )
156
- . map ( ( { path } ) => path )
157
- . join ( '' ) ;
156
+ . map ( ( { path } ) => path ) ;
157
+
158
+ // Join all parts with '/', then replace multiple slashes with a single one.
159
+ let fullPath = pathParts . join ( '/' ) ;
160
+ fullPath = fullPath . replace ( / \/ + / g, '/' ) ;
161
+
162
+ // Edge case: If the path started with multiple slashes and routes,
163
+ // like `//foo`, it might become `/foo`. This is generally acceptable.
164
+
165
+ return fullPath ;
158
166
}
Original file line number Diff line number Diff line change @@ -64,6 +64,11 @@ describe('browserTracingReactRouterV3', () => {
64
64
< Route path = ":orgid" component = { ( ) => < div > OrgId</ div > } />
65
65
< Route path = ":orgid/v1/:teamid" component = { ( ) => < div > Team</ div > } />
66
66
</ Route >
67
+ < Route path = "teams" >
68
+ < Route path = ":teamId" >
69
+ < Route path = "details" component = { ( ) => < div > Team Details</ div > } />
70
+ </ Route >
71
+ </ Route >
67
72
</ Route >
68
73
) ;
69
74
const history = createMemoryHistory ( ) ;
@@ -192,6 +197,22 @@ describe('browserTracingReactRouterV3', () => {
192
197
[ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'navigation' ,
193
198
} ,
194
199
} ) ;
200
+ expect ( getCurrentScope ( ) . getScopeData ( ) . transactionName ) . toEqual ( '/users/:userid' ) ;
201
+
202
+ act ( ( ) => {
203
+ history . push ( '/teams/456/details' ) ;
204
+ } ) ;
205
+
206
+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenCalledTimes ( 2 ) ;
207
+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenLastCalledWith ( expect . any ( BrowserClient ) , {
208
+ name : '/teams/:teamId/details' ,
209
+ attributes : {
210
+ [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' ,
211
+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.navigation.react.reactrouter_v3' ,
212
+ [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'navigation' ,
213
+ } ,
214
+ } ) ;
215
+ expect ( getCurrentScope ( ) . getScopeData ( ) . transactionName ) . toEqual ( '/teams/:teamId/details' ) ;
195
216
} ) ;
196
217
197
218
it ( "updates the scope's `transactionName` on a navigation" , ( ) => {
You can’t perform that action at this time.
0 commit comments