diff --git a/lib/codecov.js b/lib/codecov.js index ad0cb2a2..bb830b79 100644 --- a/lib/codecov.js +++ b/lib/codecov.js @@ -556,6 +556,9 @@ var upload = function(args, on_success, on_failure) { } function sanitizeVar(arg) { + if (!arg) { + return '' + } return arg.replace(/&/g, '') } diff --git a/test/index.test.js b/test/index.test.js index 7fd11431..77d4b5ed 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -282,4 +282,10 @@ describe('Codecov', function() { 'real run unsafe command' ) }) + + it('gracefully sanitizes undefined', function() { + expect(function() { + codecov.sanitizeVar(undefined) + }).not.toThrow() + }) })