diff --git a/lib/jsdoc/util/templateHelper.js b/lib/jsdoc/util/templateHelper.js
index fa1604f2..1b967ba5 100644
--- a/lib/jsdoc/util/templateHelper.js
+++ b/lib/jsdoc/util/templateHelper.js
@@ -425,6 +425,13 @@ function splitLinkText(text) {
target = text.substr(0, splitIndex);
}
+ if (linkText) {
+ linkText = linkText.trim();
+ }
+ if (target) {
+ target = target.trim();
+ }
+
return {
linkText: linkText,
target: target || text
diff --git a/test/specs/jsdoc/util/templateHelper.js b/test/specs/jsdoc/util/templateHelper.js
index bd6d2d9b..aac38dde 100644
--- a/test/specs/jsdoc/util/templateHelper.js
+++ b/test/specs/jsdoc/util/templateHelper.js
@@ -1517,6 +1517,13 @@ describe("jsdoc/util/templateHelper", () => {
expect(output).toBe('Link to Test');
});
+ it('should not add spaces to the href or text when there are spaces around the pipe', () => {
+ const input = 'Link to {@link test | Test}';
+ const output = helper.resolveLinks(input);
+
+ expect(output).toBe('Link to Test');
+ });
+
it('should allow first space to be used as delimiter between href and text (external link)', () => {
const input = 'Link to {@link http://github.com Github}';
const output = helper.resolveLinks(input);