Skip to content

Commit

Permalink
fix: resolve GitHub CodeQL alert
Browse files Browse the repository at this point in the history
  • Loading branch information
gauthier-th committed Jun 21, 2024
1 parent 43f8260 commit 966a721
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/i18n/extractMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ async function extractMessages(
.replace(/^\s*(['"])?([a-zA-Z0-9_-]+)(['"])?:/gm, '"$2":')
.replace(
/'.*'/g,
(match) => `"${match.match(/'(.*)'/)?.[1].replace(/"/g, '\\"')}"`
(match) =>
`"${match
.match(/'(.*)'/)?.[1]
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')}"`
)
.replace(/,$/, '');
const messagesJson = JSON.parse(`{${formattedMessages}}`);
Expand Down

0 comments on commit 966a721

Please sign in to comment.