package validator import ( "strings" "testing" ) func TestValidateDomain(t *testing.T) { v := DefaultDomainValidator() tests := []struct { name string input string wantErr bool }{ {"simple domain", "example.com", false}, {"subdomain", "api.example.com", false}, {"deep subdomain", "a.b.c.example.com", false}, {"hyphen in middle", "my-site.example.com", false}, {"co.uk tld", "example.co.uk", false}, {"uppercase", "EXAMPLE.COM", false}, {"empty", "", true}, {"whitespace only", " ", true}, {"with scheme http", "http://example.com", true}, {"with scheme https", "https://example.com", true}, {"path traversal", "example.com/../etc", true}, {"shell metachar ;", "example.com;whoami", true}, {"shell metachar |", "example.com|whoami", true}, {"shell metachar &", "example.com&ls", true}, {"backtick", "example.com`id`", true}, {"dollar", "example.com$USER", true}, {"newline", "example.com\nmalicious", true}, {"null byte", "example.com\x00.evil", true}, {"leading hyphen label", "-example.com", true}, {"trailing hyphen label", "example-.com", true}, {"double dot", "example..com", true}, {"label too long", strings.Repeat("a", 64) + ".com", true}, {"domain too long", strings.Repeat("a.", 130) + "com", true}, {"numeric tld", "example.123", true}, {"single label", "localhost", true}, {"angle brackets", "