mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-10-16 20:52:30 +02:00
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
This commit is contained in:
1 parent
0b835e187b
commit
0411000662
1 file changed
+1
-1
@@ -1580,9 +1580,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @returns {[string]}
|
* @returns {[string]}
|
||||||
*/
|
*/
|
||||||
split: function split(str, re, limit) {
|
split: function split(str, re, limit) {
|
||||||
re.lastIndex = 0;
|
|
||||||
if (!re.global)
|
if (!re.global)
|
||||||
re = RegExp(re.source || re, "g");
|
re = RegExp(re.source || re, "g");
|
||||||
|
re.lastIndex = 0;
|
||||||
let match, start = 0, res = [];
|
let match, start = 0, res = [];
|
||||||
while (--limit && (match = re.exec(str)) && match[0].length) {
|
while (--limit && (match = re.exec(str)) && match[0].length) {
|
||||||
res.push(str.substring(start, match.index));
|
res.push(str.substring(start, match.index));
|
||||||
|
|||||||
Reference in new issue
Block a user