mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
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:
parent
37fc8cd3b3
commit
3d90c8a8c2
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user