From 0411000662a3e38eb5a506c70257863d2f57da6a Mon Sep 17 00:00:00 2001 From: Sebastian Kalinowski Date: Tue, 26 Apr 2016 22:31:28 +0200 Subject: [PATCH] Fix 'split' method when using String not RegExp If regular expression for splitting is provided as String instead of RegExp, it breaks split method since String doesn't have desired properties. Fixes #138 --- common/modules/util.jsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/modules/util.jsm b/common/modules/util.jsm index b76251e9..5c2bb3e8 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -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));