diff --git a/lib/jsdoc/util/templateHelper.js b/lib/jsdoc/util/templateHelper.js index 793331ba..4cd03711 100644 --- a/lib/jsdoc/util/templateHelper.js +++ b/lib/jsdoc/util/templateHelper.js @@ -233,6 +233,10 @@ function getId(longname, id) { var getUniqueId = exports.getUniqueId = makeUniqueId; var htmlsafe = exports.htmlsafe = function(str) { + if (typeof str !== 'string') { + str = String(str); + } + return str.replace(/&/g, '&') .replace(/Foo & Friends</h1>'); }); + + it('should convert non-strings to strings', function() { + function htmlsafe() { + return helper.htmlsafe(false); + } + + expect(htmlsafe).not.toThrow(); + expect(htmlsafe()).toBe('false'); + }); }); describe("find", function() {