-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
help wantedExtra attention is neededExtra attention is neededimprovementChange or improvementChange or improvement
Description
Replace JSON.parse with Misc.parseJsonWithSchema for type safety.
Example:
monkeytype/frontend/src/ts/utils/url-handler.ts
Lines 68 to 92 in 2a0a5b4
| const customThemeUrlDataSchema = z.object({ | |
| c: CustomThemeColorsSchema, | |
| i: z.string().optional(), | |
| s: CustomBackgroundSizeSchema.optional(), | |
| f: CustomBackgroundFilterSchema.optional(), | |
| }); | |
| export function loadCustomThemeFromUrl(getOverride?: string): void { | |
| const getValue = Misc.findGetParameter("customTheme", getOverride); | |
| if (getValue === null) return; | |
| let decoded: z.infer<typeof customThemeUrlDataSchema>; | |
| try { | |
| decoded = Misc.parseJsonWithSchema( | |
| atob(getValue), | |
| customThemeUrlDataSchema | |
| ); | |
| } catch (e) { | |
| console.log("Custom theme URL decoding failed", e); | |
| Notifications.add( | |
| "Failed to load theme from URL: " + (e as Error).message, | |
| 0 | |
| ); | |
| return; | |
| } |
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededimprovementChange or improvementChange or improvement