Skip to content
quarry Artifact [c0adf4bbfe]
Login

Artifact [c0adf4bbfe]

Artifact c0adf4bbfece1378b4dcf5e291958a2d663849002e7b3f1f00fa05cab274ab0c:


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&amp;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")
}