package chat
import "testing"
// Fossil's artifact clause arrives as HTML; the channel holds markdown
// links at the upstream instead, and nothing but http(s) or a path.
func TestFossilAnchorsBecomeMarkdownAtTheUpstream(t *testing.T) {
up := "https://fossil.example/home"
for in, want := range map[string]string{
"x (check-in: <a href='/r/libfossil/info/6df13e'>6df13e</a>, user: <a href='/r/libfossil/timeline?u=d&c=6df'>d</a>)": "x (check-in: [6df13e](https://fossil.example/r/libfossil/info/6df13e), user: [d](https://fossil.example/r/libfossil/timeline?u=d&c=6df))",
`<a href="javascript:alert(1)">click</a>`: "click",
`<a href='//evil.example/x'>x</a>`: "x",
"no anchors here": "no anchors here",
} {
if got := anchorsAsMarkdown(in, up); got != want {
t.Errorf("FAIL: %q\n got %q\nwant %q", in, got, want)
}
}
t.Log("ok")
}