diff --git a/src/raven.js b/src/raven.js index b099d2a7dfbc..7a2f79474ddb 100644 --- a/src/raven.js +++ b/src/raven.js @@ -644,12 +644,14 @@ function joinRegExp(patterns) { // Be mad. var sources = [], i = patterns.length; while (i--) { - sources[i] = isString(patterns[i]) ? - // If it's a string, we need to escape it - // Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions - patterns[i].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") : - // If it's a regexp already, we want to extract the source - patterns[i].source; + if (!isUndefined(patterns[i]) && patterns[i]) { + sources[i] = isString(patterns[i]) ? + // If it's a string, we need to escape it + // Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions + patterns[i].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") : + // If it's a regexp already, we want to extract the source + patterns[i].source; + } } return new RegExp(sources.join('|'), 'i'); } diff --git a/test/raven.test.js b/test/raven.test.js index 67c605ff7408..14736ffad69c 100644 --- a/test/raven.test.js +++ b/test/raven.test.js @@ -873,6 +873,12 @@ describe('globals', function() { 'a', 'b', 'a.b', /d/, /[0-9]/ ]).source, 'a|b|a\\.b|d|[0-9]'); }); + + it('should not process empty or undefined variables', function() { + assert.equal(joinRegExp([ + 'a', 'b', null, undefined + ]).source, 'a|b'); + }); }); });