File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ export const getThemeCookie = (): string | null => {
88 const themeCookie = cookies . find ( ( cookie ) => cookie . trim ( ) . startsWith ( `${ THEME_COOKIE_NAME } =` ) )
99
1010 if ( themeCookie ) {
11- return themeCookie . split ( '=' ) [ 1 ]
11+ const parts = themeCookie . split ( '=' )
12+ // Safe boundary check: ensure we have at least 2 parts and the value is not empty
13+ return parts . length >= 2 && parts [ 1 ] ? parts [ 1 ] : null
1214 }
1315
1416 return null
@@ -32,7 +34,9 @@ export const parseThemeCookie = (cookieString: string): string => {
3234 const themeCookie = cookies . find ( ( cookie ) => cookie . trim ( ) . startsWith ( `${ THEME_COOKIE_NAME } =` ) )
3335
3436 if ( themeCookie ) {
35- return themeCookie . split ( '=' ) [ 1 ] || 'true'
37+ const parts = themeCookie . split ( '=' )
38+ // Safe boundary check: ensure we have at least 2 parts and the value is not empty
39+ return parts . length >= 2 && parts [ 1 ] ? parts [ 1 ] : 'true'
3640 }
3741
3842 return 'true'
You can’t perform that action at this time.
0 commit comments