1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-25 13:12:26 +01:00

Merge pull request #151 from prmtl/fix/re-as-string

Fix 'split' method when using String not RegExp
This commit is contained in:
dkearns
2016-04-29 15:03:02 +10:00

View File

@@ -1580,9 +1580,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @returns {[string]}
*/
split: function split(str, re, limit) {
re.lastIndex = 0;
if (!re.global)
re = RegExp(re.source || re, "g");
re.lastIndex = 0;
let match, start = 0, res = [];
while (--limit && (match = re.exec(str)) && match[0].length) {
res.push(str.substring(start, match.index));