internal/httpd/flash_test.go

v1.41.0
gitbay/internal/httpd/flash_test.go history · blame · raw

19 lines · 412 bytes

 1package httpd
 2
 3import "testing"
 4
 5func TestLocalPath(t *testing.T) {
 6	for p, want := range map[string]bool{
 7		"/settings":       true,
 8		"/a/b?c=d":        true,
 9		"":                false,
10		"settings":        false,
11		"//evil.example":  false,
12		`/\evil.example`:  false,
13		"https://x.test/": false,
14	} {
15		if got := localPath(p); got != want {
16			t.Errorf("localPath(%q) = %v, want %v", p, got, want)
17		}
18	}
19}