File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
dev-packages/e2e-tests/test-applications/react-router-7-lazy-routes/tests Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ import { waitForTransaction } from '@sentry-internal/test-utils';
4
4
5
5
test ( 'Creates a pageload transaction with parameterized route' , async ( { page } ) => {
6
6
const transactionPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
7
- console . debug ( 'transactionEvent' , transactionEvent ) ;
8
-
9
7
return (
10
8
! ! transactionEvent ?. transaction &&
11
9
transactionEvent . contexts ?. trace ?. op === 'pageload' &&
Original file line number Diff line number Diff line change @@ -66,11 +66,24 @@ const allRoutes = new Set<RouteObject>();
66
66
67
67
/**
68
68
* Adds resolved routes as children to the parent route.
69
+ * Prevents duplicate routes by checking if they already exist.
69
70
*/
70
71
function addResolvedRoutesToParent ( resolvedRoutes : RouteObject [ ] , parentRoute : RouteObject ) : void {
71
- parentRoute . children = Array . isArray ( parentRoute . children )
72
- ? [ ...parentRoute . children , ...resolvedRoutes ]
73
- : resolvedRoutes ;
72
+ const existingChildren = parentRoute . children || [ ] ;
73
+
74
+ const newRoutes = resolvedRoutes . filter (
75
+ newRoute =>
76
+ ! existingChildren . some (
77
+ existing =>
78
+ existing === newRoute ||
79
+ ( newRoute . path && existing . path === newRoute . path ) ||
80
+ ( newRoute . id && existing . id === newRoute . id ) ,
81
+ ) ,
82
+ ) ;
83
+
84
+ if ( newRoutes . length > 0 ) {
85
+ parentRoute . children = [ ...existingChildren , ...newRoutes ] ;
86
+ }
74
87
}
75
88
76
89
/**
You can’t perform that action at this time.
0 commit comments