@@ -50,6 +50,16 @@ func TestDomainValidator_SafeHostname(t *testing.T) {
5050 input : "https://example.com" ,
5151 expected : "example.com" ,
5252 },
53+ {
54+ description : "Domain with underscores should pass" ,
55+ input : "https://my_domain.com" ,
56+ expected : "my_domain.com" ,
57+ },
58+ {
59+ description : "Domain with leading hyphen should pass" ,
60+ input : "https://-my-domain.com" ,
61+ expected : "-my-domain.com" ,
62+ },
5363 {
5464 description : "Domain without scheme should parse if scheme is disabled" ,
5565 input : "example.com" ,
@@ -108,7 +118,7 @@ func TestDomainValidator_SafeHostname(t *testing.T) {
108118 },
109119 {
110120 description : "Invalid IDNA domain should fail" ,
111- input : "ab--cd .example.com" ,
121+ input : "xn--r-kva .example.com" ,
112122 errorFunc : func (t * testing.T , e error ) {
113123 assert .ErrorContains (t , e , "invalid label" )
114124 },
@@ -196,7 +206,7 @@ func TestDomainValidator_Validate(t *testing.T) {
196206 },
197207 {
198208 description : "Failure to format expected domain should fail" ,
199- expected : "ab--cd .example.com" ,
209+ expected : "xn--r-kva .example.com" ,
200210 actual : "example.com" ,
201211 errorFunc : func (t * testing.T , e error ) {
202212 assert .ErrorContains (t , e , "idna: invalid label" )
@@ -205,7 +215,7 @@ func TestDomainValidator_Validate(t *testing.T) {
205215 {
206216 description : "Failure to format check domain should fail" ,
207217 expected : "example.com" ,
208- actual : "ab--cd .example.com" ,
218+ actual : "xn--r-kva .example.com" ,
209219 errorFunc : func (t * testing.T , e error ) {
210220 assert .ErrorContains (t , e , "idna: invalid label" )
211221 },
0 commit comments