package webpath import "testing" func TestNormalizePublicURL(t *testing.T) { t.Parallel() tests := []struct { raw string want string allow bool }{ {"https://91jxporn.com/avtopic/", "https://91jxporn.com/video/all", true}, {"https://91jxporn.com/dh/", "https://91jxporn.com/nav", true}, {"https://91jxporn.com/richtext?title=test", "https://91jxporn.com/richtext?title=test", true}, {"https://91jxporn.com/topic/", "", false}, {"https://91jxporn.com/tag/all/", "", false}, {"https://91jxporn.com/useragreement/", "", false}, } for _, tt := range tests { got, ok := NormalizePublicURL(tt.raw) if ok != tt.allow { t.Fatalf("NormalizePublicURL(%q) allow = %v, want %v", tt.raw, ok, tt.allow) } if !tt.allow { continue } if got != tt.want { t.Fatalf("NormalizePublicURL(%q) = %q, want %q", tt.raw, got, tt.want) } } } func TestNormalizePublicPath(t *testing.T) { t.Parallel() got, ok := NormalizePublicPath("/avtopic/") if !ok || got != "/video/all" { t.Fatalf("NormalizePublicPath(/avtopic/) = %q, %v", got, ok) } }