diff --git a/lib/jsdoc/util/templateHelper.js b/lib/jsdoc/util/templateHelper.js index cdef6e16..b40e0ea7 100644 --- a/lib/jsdoc/util/templateHelper.js +++ b/lib/jsdoc/util/templateHelper.js @@ -567,14 +567,18 @@ exports.resolveLinks = function(str) { /** Convert tag text like "Jane Doe " into a mailto link */ exports.resolveAuthorLinks = function(str) { - var author; - var matches = str.match(/^\s?([\s\S]+)\b\s+<(\S+@\S+)>\s?$/); + var author = ''; + var matches; - if (matches && matches.length === 3) { - author = '' + htmlsafe(matches[1]) + ''; - } - else { - author = htmlsafe(str); + if (str) { + matches = str.match(/^\s?([\s\S]+)\b\s+<(\S+@\S+)>\s?$/); + + if (matches && matches.length === 3) { + author = '' + htmlsafe(matches[1]) + ''; + } + else { + author = htmlsafe(str); + } } return author; diff --git a/test/specs/jsdoc/util/templateHelper.js b/test/specs/jsdoc/util/templateHelper.js index 137fe1a5..60be0437 100644 --- a/test/specs/jsdoc/util/templateHelper.js +++ b/test/specs/jsdoc/util/templateHelper.js @@ -1840,6 +1840,14 @@ describe("jsdoc/util/templateHelper", function() { }); describe("resolveAuthorLinks", function() { + it('should not crash JSDoc if no text is specified', function() { + function resolve() { + helper.resolveAuthorLinks(); + } + + expect(resolve).not.toThrow(); + }); + // convert Jane Doe to a mailto link. it('should convert email addresses in angle brackets *after* a name to mailto links', function() { var str = ' John Doe ';