Files
chorus/portal/handler/router_test.go
T

24 lines
514 B
Go

package handler
import "testing"
func TestSafeReturnTo(t *testing.T) {
tests := []struct {
input string
want string
}{
{"", "/"},
{"/", "/"},
{"/generations/12?tab=result", "/generations/12?tab=result"},
{"//example.invalid", "/"},
{"/\\example.invalid", "/"},
{"https://example.invalid", "/"},
{"/line\nbreak", "/"},
}
for _, test := range tests {
if got := safeReturnTo(test.input); got != test.want {
t.Errorf("safeReturnTo(%q) = %q, want %q", test.input, got, test.want)
}
}
}