diff --git a/components/codeChecker/validate.ts b/components/codeChecker/validate.ts index 482d2adcee..64e9f5eb06 100644 --- a/components/codeChecker/validate.ts +++ b/components/codeChecker/validate.ts @@ -38,7 +38,8 @@ const constants = { const validateCanvasCreation = ( sketchFileContent: string, ): Result => { - const canvasMatch = constants.canvasRegex.exec(sketchFileContent) + // Create a new regex instance to avoid issues with lastIndex when using the global flag. + const canvasMatch = new RegExp(constants.canvasRegex).exec(sketchFileContent) if (!canvasMatch) { return { isSuccess: false, error: 'createCanvas function not found.' } }