Skip to content

Commit

Permalink
use fallback if json parse error for logo env's
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Sep 3, 2024
1 parent cc8885d commit acd44b5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions care.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ interface ILogo {
}

const logo = (value?: string, fallback?: ILogo) => {
return value ? (JSON.parse(value) as ILogo) : fallback;
if (!value) {
return fallback;
}

try {
return JSON.parse(value) as ILogo;
} catch {
// TODO: define vite plugin to validate care.config.ts during build step
return fallback;
}
};

const careConfig = {
apiUrl: env.REACT_CARE_API_URL,

Expand Down

0 comments on commit acd44b5

Please sign in to comment.