fix: resolve GitHub CodeQL alert

This commit is contained in:
gauthier-th
2024-06-21 19:11:45 +02:00
parent 43f8260675
commit 966a721c54

View File

@@ -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}}`);