Skip to content

Commit 61d5b88

Browse files
committed
Merge pull request #179 from johnbacon/patch-1
Update raven.js to work around IE8 shortcomings
2 parents cdc4339 + fdac9de commit 61d5b88

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/raven.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,12 +644,14 @@ function joinRegExp(patterns) {
644644
// Be mad.
645645
var sources = [], i = patterns.length;
646646
while (i--) {
647-
sources[i] = isString(patterns[i]) ?
648-
// If it's a string, we need to escape it
649-
// Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
650-
patterns[i].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") :
651-
// If it's a regexp already, we want to extract the source
652-
patterns[i].source;
647+
if (!isUndefined(patterns[i]) && patterns[i]) {
648+
sources[i] = isString(patterns[i]) ?
649+
// If it's a string, we need to escape it
650+
// Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
651+
patterns[i].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") :
652+
// If it's a regexp already, we want to extract the source
653+
patterns[i].source;
654+
}
653655
}
654656
return new RegExp(sources.join('|'), 'i');
655657
}

test/raven.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,12 @@ describe('globals', function() {
873873
'a', 'b', 'a.b', /d/, /[0-9]/
874874
]).source, 'a|b|a\\.b|d|[0-9]');
875875
});
876+
877+
it('should not process empty or undefined variables', function() {
878+
assert.equal(joinRegExp([
879+
'a', 'b', null, undefined
880+
]).source, 'a|b');
881+
});
876882
});
877883
});
878884

0 commit comments

Comments
 (0)