Skip to content

Commit 3e08293

Browse files
committed
Neatened up this for loop a bit
1 parent f3baeee commit 3e08293

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/raven.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,15 +642,19 @@ function isSetup() {
642642
function joinRegExp(patterns) {
643643
// Combine an array of regular expressions and strings into one large regexp
644644
// Be mad.
645-
var sources = [], len = patterns.length;
646-
for (var i = 0; i < len; i++) {
647-
if (isString(patterns[i])) {
645+
var sources = [],
646+
i = 0, len = patterns.length,
647+
pattern;
648+
649+
for (; i < len; i++) {
650+
pattern = patterns[i];
651+
if (isString(pattern)) {
648652
// If it's a string, we need to escape it
649653
// Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
650-
sources.push(patterns[i].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"));
651-
} else if (patterns[i] && patterns[i].source) {
654+
sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"));
655+
} else if (pattern && pattern.source) {
652656
// If it's a regexp already, we want to extract the source
653-
sources.push(patterns[i].source);
657+
sources.push(pattern.source);
654658
}
655659
// Intentionally skip other cases
656660
}

0 commit comments

Comments
 (0)