mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
fix crash when the author tag is empty (#1289)
This commit is contained in:
parent
43a117d6a1
commit
f1017988ec
@ -567,8 +567,11 @@ exports.resolveLinks = function(str) {
|
||||
|
||||
/** Convert tag text like "Jane Doe <jdoe@example.org>" 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 (str) {
|
||||
matches = str.match(/^\s?([\s\S]+)\b\s+<(\S+@\S+)>\s?$/);
|
||||
|
||||
if (matches && matches.length === 3) {
|
||||
author = '<a href="mailto:' + matches[2] + '">' + htmlsafe(matches[1]) + '</a>';
|
||||
@ -576,6 +579,7 @@ exports.resolveAuthorLinks = function(str) {
|
||||
else {
|
||||
author = htmlsafe(str);
|
||||
}
|
||||
}
|
||||
|
||||
return author;
|
||||
};
|
||||
|
||||
@ -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 <jdoe@example.org> to a mailto link.
|
||||
it('should convert email addresses in angle brackets *after* a name to mailto links', function() {
|
||||
var str = ' John Doe <asdf.fdsa-2@gmail.com> ';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user