mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-29 17:32:43 +00:00
Wrap all JSON.parse calls with try-catch
This commit is contained in:
@@ -623,3 +623,11 @@ export function makeDescriptionId(prefix: string, id: Identifier | undefined) {
|
||||
}
|
||||
return `${prefix}.${id.namespace}.${id.path.replaceAll('/', '.')}`
|
||||
}
|
||||
|
||||
export function safeJsonParse(text: string): any {
|
||||
try {
|
||||
return JSON.parse(text)
|
||||
} catch (e) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user