File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
dev-packages/e2e-tests/test-applications/react-router-7-lazy-routes/tests Expand file tree Collapse file tree 2 files changed +14
-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,22 @@ 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 ( newRoute =>
75
+ ! existingChildren . some ( existing =>
76
+ existing === newRoute ||
77
+ ( newRoute . path && existing . path === newRoute . path ) ||
78
+ ( newRoute . id && existing . id === newRoute . id )
79
+ )
80
+ ) ;
81
+
82
+ if ( newRoutes . length > 0 ) {
83
+ parentRoute . children = [ ...existingChildren , ...newRoutes ] ;
84
+ }
74
85
}
75
86
76
87
/**
You can’t perform that action at this time.
0 commit comments