mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-21 01:53:20 +00:00
fix hyperlinks getting lost across AI features
AI grammar fix rewrote the draft as plain text, so links in the reply box were dropped. It now sends the editor HTML and asks the model to keep tags. Conversation transcripts, the AI agent history and copilot context also stripped link URLs when converting HTML to text, so the model never saw them. They now keep links as "text ( url )".
This commit is contained in:
@@ -296,3 +296,34 @@ func TestSplitName(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTML2TextWithLinks(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
html string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "link with distinct text keeps url",
|
||||
html: `<p>See <a href="https://example.com/guide">the guide</a> for steps.</p>`,
|
||||
want: "See the guide ( https://example.com/guide ) for steps.",
|
||||
},
|
||||
{
|
||||
name: "link text equal to url not duplicated",
|
||||
html: `<p><a href="https://example.com">https://example.com</a></p>`,
|
||||
want: "https://example.com",
|
||||
},
|
||||
{
|
||||
name: "plain text unchanged",
|
||||
html: `<p>No links here.</p>`,
|
||||
want: "No links here.",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := HTML2TextWithLinks(tt.html); got != tt.want {
|
||||
t.Errorf("got %q, want %q", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user