Escape syntax character in regex

Syntax characters need to be escaped when they are part of a regex.

https://tc39.es/ecma262/#prod-Atom
https://tc39.es/ecma262/#prod-PatternCharacter
This commit is contained in:
Lucas Mirelmann 2025-04-18 19:59:02 +02:00 committed by Ms2ger
parent c5257e6119
commit 34b0db5fb0

View File

@ -261,7 +261,7 @@ function testBound(fun)
testBound(strict);
testBound(nonstrict);
var nativeFunctionRegex = /^function\s*\(\)\s*{\s*\[native code\]\s*}$/
var nativeFunctionRegex = /^function\s*\(\)\s*\{\s*\[native code\]\s*\}$/
assert.sameValue(nativeFunctionRegex.test((function unbound(){"body"}).bind().toString()), true);