package app import "testing" func TestValidateExternalHTTPSURL(t *testing.T) { valid := []string{ "https://github.com/Nwflower/Reims-Go", " https://discord.gg/Tj682rW5rS ", "https://github.com/Nwflower/Reims-Go/releases/tag/v0.2.10?foo=1#notes", } for _, raw := range valid { if _, err := validateExternalHTTPSURL(raw); err != nil { t.Errorf("validateExternalHTTPSURL(%q) unexpected error: %v", raw, err) } } invalid := []string{ "", "http://example.com", "javascript:alert(1)", "file:///C:/Windows/System32/calc.exe", "https://", "https://user:pass@example.com/path", "https://example.com/a b", "https://example.com/a\nfoo", "https://example.com/\"quoted\"", "https://example.com/a\x00b", } for _, raw := range invalid { if got, err := validateExternalHTTPSURL(raw); err == nil { t.Errorf("validateExternalHTTPSURL(%q) = %q, want error", raw, got) } } }