Skip to content

Commit

Permalink
[Robustness] use call-bound indexOf
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 19, 2022
1 parent 798d359 commit b035fdc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions regexp-matchall.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ var ToLength = require('es-abstract/2021/ToLength');
var ToString = require('es-abstract/2021/ToString');
var Type = require('es-abstract/2021/Type');
var flagsGetter = require('regexp.prototype.flags');
var callBound = require('call-bind/callBound');

var $indexOf = callBound('String.prototype.indexOf');

var OrigRegExp = RegExp;

Expand Down Expand Up @@ -45,8 +48,8 @@ var regexMatchAll = function SymbolMatchAll(string) {

var lastIndex = ToLength(Get(R, 'lastIndex'));
Set(matcher, 'lastIndex', lastIndex, true);
var global = flags.indexOf('g') > -1;
var fullUnicode = flags.indexOf('u') > -1;
var global = $indexOf(flags, 'g') > -1;
var fullUnicode = $indexOf(flags, 'u') > -1;
return CreateRegExpStringIterator(matcher, S, global, fullUnicode);
};

Expand Down

0 comments on commit b035fdc

Please sign in to comment.