package domain import "testing" func TestValidateURL(t *testing.T) { tests := []struct { input string want string ok bool }{ {"https://www.youtube.com/watch?v=123", "https://www.youtube.com/watch?v=123", true}, {"http://example.com/video", "http://example.com/video", true}, {"https://vimeo.com/123456", "https://vimeo.com/123456", true}, {"https://www.pornhub.com/view_video.php?viewkey=123", "https://www.pornhub.com/view_video.php?viewkey=123", true}, {"", "", false}, {"not a url", "", false}, {"ftp://example.com", "", false}, {" https://example.com ", "https://example.com", true}, } for _, tt := range tests { got, ok := ValidateURL(tt.input) if ok != tt.ok || (ok && got != tt.want) { t.Errorf("ValidateURL(%q) = (%q, %v), want (%q, %v)", tt.input, got, ok, tt.want, tt.ok) } } }