File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
packages/nextjs/src/client/routing Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,26 @@ const globalWithInjectedManifest = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
66} ;
77
88export const maybeParameterizeRoute = ( route : string ) : string | undefined => {
9- const manifest = globalWithInjectedManifest . _sentryRouteManifest ;
9+ if (
10+ ! globalWithInjectedManifest . _sentryRouteManifest ||
11+ typeof globalWithInjectedManifest . _sentryRouteManifest !== 'string'
12+ ) {
13+ return undefined ;
14+ }
1015
11- if ( ! manifest ) {
16+ let manifest : RouteManifest = {
17+ staticRoutes : [ ] ,
18+ dynamicRoutes : [ ] ,
19+ } ;
20+
21+ // Shallow check if the manifest is actually what we expect it to be
22+ try {
23+ manifest = JSON . parse ( globalWithInjectedManifest . _sentryRouteManifest ) ;
24+ if ( ! Array . isArray ( manifest . staticRoutes ) || ! Array . isArray ( manifest . dynamicRoutes ) ) {
25+ return undefined ;
26+ }
27+ } catch ( error ) {
28+ // Something went wrong while parsing the manifest, so we'll fallback to no parameterization
1229 return undefined ;
1330 }
1431
You can’t perform that action at this time.
0 commit comments