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 "(\\"|[^\"])*"
// single quotes '(\\'|[^'])*'
// 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
// note we only support ; statement delimiters:
@ -298,7 +303,7 @@ function genRX(
// [^;]
//
const statementRe =
/(\/(\\\/|[^\/])*\/|"(\\"|[^\"])*"|'(\\'|[^'])*'|`(\\`|[^`])*`|[^;])+/gm
/(\/(\\\/|[^\/])*\/|"(\\"|[^\"])*"|'(\\'|[^'])*'|`(\\`|[^`])*`|\(\s*((function)\s*\(\s*\)|(\(\s*\))\s*=>)\s*(?:\{[\s\S]*?\}|[^;)\{]*)\s*\)\s*\(\s*\)|[^;])+/gm
const statements = ctx.value.trim().match(statementRe)
if (statements) {
const lastIdx = statements.length - 1