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,14 +567,18 @@ exports.resolveLinks = function(str) {
|
|||||||
|
|
||||||
/** Convert tag text like "Jane Doe <jdoe@example.org>" into a mailto link */
|
/** Convert tag text like "Jane Doe <jdoe@example.org>" into a mailto link */
|
||||||
exports.resolveAuthorLinks = function(str) {
|
exports.resolveAuthorLinks = function(str) {
|
||||||
var author;
|
var author = '';
|
||||||
var matches = str.match(/^\s?([\s\S]+)\b\s+<(\S+@\S+)>\s?$/);
|
var matches;
|
||||||
|
|
||||||
if (matches && matches.length === 3) {
|
if (str) {
|
||||||
author = '<a href="mailto:' + matches[2] + '">' + htmlsafe(matches[1]) + '</a>';
|
matches = str.match(/^\s?([\s\S]+)\b\s+<(\S+@\S+)>\s?$/);
|
||||||
}
|
|
||||||
else {
|
if (matches && matches.length === 3) {
|
||||||
author = htmlsafe(str);
|
author = '<a href="mailto:' + matches[2] + '">' + htmlsafe(matches[1]) + '</a>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
author = htmlsafe(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return author;
|
return author;
|
||||||
|
|||||||
@ -1840,6 +1840,14 @@ describe("jsdoc/util/templateHelper", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("resolveAuthorLinks", 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.
|
// 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() {
|
it('should convert email addresses in angle brackets *after* a name to mailto links', function() {
|
||||||
var str = ' John Doe <asdf.fdsa-2@gmail.com> ';
|
var str = ' John Doe <asdf.fdsa-2@gmail.com> ';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user