This commit is contained in:
Casey Link 2025-04-19 23:21:24 +02:00 committed by GitHub
commit eedbe0e336
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -291,6 +291,11 @@ function genRX(
// double quotes "(\\"|[^\"])*" // double quotes "(\\"|[^\"])*"
// single quotes '(\\'|[^'])*' // single quotes '(\\'|[^'])*'
// ticks `(\\`|[^`])*` // ticks `(\\`|[^`])*`
// iife \(\s*((function)\s*\(\s*\)|(\(\s*\))\s*=>)\s*(?:\{[\s\S]*?\}|[^;)\{]*)\s*\)\s*\(\s*\)
//
// The iife support is (intentionally) limited. It only supports
// function and arrow syntax with no arguments, and does not support nested
// IIFEs.
// //
// We also want to match the non delimiter part of statements // We also want to match the non delimiter part of statements
// note we only support ; statement delimiters: // note we only support ; statement delimiters:
@ -298,7 +303,7 @@ function genRX(
// [^;] // [^;]
// //
const statementRe = const statementRe =
/(\/(\\\/|[^\/])*\/|"(\\"|[^\"])*"|'(\\'|[^'])*'|`(\\`|[^`])*`|[^;])+/gm /(\/(\\\/|[^\/])*\/|"(\\"|[^\"])*"|'(\\'|[^'])*'|`(\\`|[^`])*`|\(\s*((function)\s*\(\s*\)|(\(\s*\))\s*=>)\s*(?:\{[\s\S]*?\}|[^;)\{]*)\s*\)\s*\(\s*\)|[^;])+/gm
const statements = ctx.value.trim().match(statementRe) const statements = ctx.value.trim().match(statementRe)
if (statements) { if (statements) {
const lastIdx = statements.length - 1 const lastIdx = statements.length - 1