mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Bulletproof getCountOfAllMatches against non-global regex input
FREEBIE
This commit is contained in:
@@ -21,6 +21,10 @@
|
||||
var match = regex.exec(str);
|
||||
var count = 0;
|
||||
|
||||
if (!regex.global) {
|
||||
return match ? 1 : 0;
|
||||
}
|
||||
|
||||
while (match) {
|
||||
count += 1;
|
||||
match = regex.exec(str);
|
||||
|
||||
Reference in New Issue
Block a user