fix: in inline links, strip spaces around pipe character

Previously, if you had an inline link tag like `{@link https://example.com/ | link text}`, then the link URL ended up being `https://example.com/%20`.
This commit is contained in:
Jeff Williams 2023-02-16 08:20:13 -08:00
parent 37fc8cd3b3
commit 3d90c8a8c2
No known key found for this signature in database
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -1517,6 +1517,13 @@ describe("jsdoc/util/templateHelper", () => {
expect(output).toBe('Link to <a href="path/to/test.html">Test</a>');
});
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 <a href="path/to/test.html">Test</a>');
});
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);