aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/web_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/web_test.go')
-rw-r--r--internal/web/web_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/web/web_test.go b/internal/web/web_test.go
index 42d3b3a..7f66085 100644
--- a/internal/web/web_test.go
+++ b/internal/web/web_test.go
@@ -1003,3 +1003,14 @@ func TestHTTPSAndTrustProxy(t *testing.T) {
t.Errorf("clientIP without TRUST_PROXY = %q, want the peer", ip)
}
}
+
+func TestSafeNext(t *testing.T) {
+ for in, want := range map[string]string{
+ "/b/alice/": "/b/alice/", "/dashboard?x=1": "/dashboard?x=1",
+ "//evil.com": "", `/\evil.com`: "", `/b/\x/`: "", "http://evil.com": "", "dashboard": "", "": "",
+ } {
+ if got := safeNext(in); got != want {
+ t.Errorf("safeNext(%q) = %q, want %q", in, got, want)
+ }
+ }
+}