mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 20:01:24 +00:00
fix(tui): prevent duplicate URL display for autolinked emails (#888)
Autolinked emails like user@example.com were rendered as 'user@example.com (mailto:user@example.com)' because the comparison token.text === token.href failed (text lacks mailto: prefix). Now strips mailto: prefix before comparing, so autolinked emails display without redundant URL in parentheses.
This commit is contained in:
parent
0363a10c69
commit
620239bd3f
3 changed files with 58 additions and 1 deletions
|
|
@ -379,7 +379,10 @@ export class Markdown implements Component {
|
|||
const linkText = this.renderInlineTokens(token.tokens || []);
|
||||
// If link text matches href, only show the link once
|
||||
// Compare raw text (token.text) not styled text (linkText) since linkText has ANSI codes
|
||||
if (token.text === token.href) {
|
||||
// For mailto: links, strip the prefix before comparing (autolinked emails have
|
||||
// text="foo@bar.com" but href="mailto:foo@bar.com")
|
||||
const hrefForComparison = token.href.startsWith("mailto:") ? token.href.slice(7) : token.href;
|
||||
if (token.text === token.href || token.text === hrefForComparison) {
|
||||
result += this.theme.link(this.theme.underline(linkText)) + this.getDefaultStylePrefix();
|
||||
} else {
|
||||
result +=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue