Skip to content

Commit

Permalink
add(codeChecker/validate.ts): validate postMessageKoda is used
Browse files Browse the repository at this point in the history
  • Loading branch information
hassnian committed Oct 19, 2024
1 parent 24b35b3 commit b955523
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/codeChecker/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const constants = {
localP5JsRegex: /<script.*src="(?!http)([^"]*p5[^"]*\.js)"/,
titleTagRegex: /<title>(.*?)<\/title>/,
kodaRendererRegex: /kodahash\/render\/completed/,
kodaRendererCalledRegex: /(?<!function\s)postMessageKoda\s*\(/,
resizerRegex: /resizeCanvas\(/,
disallowedTitle: 'KodaHash',
}
Expand Down Expand Up @@ -141,7 +142,7 @@ const validateSketchContent = (
canvasSize,
localP5jsUsed: false, // This will be set based on HTML content checks
validTitle: false, // This will be updated after HTML content checks
kodaRendererUsed: constants.kodaRendererRegex.test(sketchFileContent),
kodaRendererUsed: constants.kodaRendererRegex.test(sketchFileContent) && constants.kodaRendererCalledRegex.test(sketchFileContent),
resizerUsed: constants.resizerRegex.test(sketchFileContent),
usesHashParam: validateURLParamsUsage(sketchFileContent).isSuccess,
}
Expand Down

0 comments on commit b955523

Please sign in to comment.