RESOLVED FIXED 210671
Web Inspector: REGRESSION(r242018): using `RegExp.prototype.test` with a global `RegExp` will ignore one potential match after each successful match
https://bugs.webkit.org/show_bug.cgi?id=210671
Summary Web Inspector: REGRESSION(r242018): using `RegExp.prototype.test` with a glob...
Devin Rousso
Reported 2020-04-17 13:58:17 PDT
``` let x = /script/gi; console.log(x.test("script")); // true console.log(x.test("script")); // false console.log(x.test("script")); // true console.log(x.test("script")); // false ``` this is due to the nature of `lastIndex`, which is set when using a global `RegExp` (see 12.a in <https://tc39.es/ecma262/#sec-regexpbuiltinexec>)
Attachments
Patch (13.94 KB, patch)
2020-04-17 14:09 PDT, Devin Rousso
no flags
Patch (13.96 KB, patch)
2020-04-17 14:13 PDT, Devin Rousso
no flags
Devin Rousso
Comment 1 2020-04-17 14:09:39 PDT
Devin Rousso
Comment 2 2020-04-17 14:13:56 PDT
Created attachment 396797 [details] Patch use better names :P
Radar WebKit Bug Importer
Comment 3 2020-04-17 14:17:52 PDT
EWS
Comment 4 2020-04-17 15:33:10 PDT
Committed r260291: <https://trac.webkit.org/changeset/260291> All reviewed patches have been landed. Closing bug and clearing flags on attachment 396797 [details].
Blaze Burg
Comment 5 2020-04-20 09:41:48 PDT
(In reply to Devin Rousso from comment #0) > ``` > let x = /script/gi; > console.log(x.test("script")); // true > console.log(x.test("script")); // false > console.log(x.test("script")); // true > console.log(x.test("script")); // false > ``` > > this is due to the nature of `lastIndex`, which is set when using a global > `RegExp` (see 12.a in <https://tc39.es/ecma262/#sec-regexpbuiltinexec>) Wut.
Note You need to log in before you can comment on or make changes to this bug.