validator icon indicating copy to clipboard operation
validator copied to clipboard

Hostname ends with capital character is not accepted

Open ki-ichino-nec opened this issue 6 years ago • 2 comments

Package version eg. v8, v9:

v9

Issue, Question or Enhancement:

The validator says the hostname which ends with a capital character is invalid. The regular expression [-Az] in regexes.go may be incorrect.

regexes.go

const (
	// ...
	hostnameRegexStringRFC952        = `^[a-zA-Z][a-zA-Z0-9\-\.]+[a-z-Az0-9]$`    // https://tools.ietf.org/html/rfc952
	hostnameRegexStringRFC1123       = `^[a-zA-Z0-9][a-zA-Z0-9\-\.]+[a-z-Az0-9]$` // accepts hostname starting with a digit https://tools.ietf.org/html/rfc1123
	// ...
)

Code sample, to showcase or reproduce:

validate.Var("aaA", "hostname")

ki-ichino-nec avatar Jan 07 '19 04:01 ki-ichino-nec

Thanks, I'll take a look when I'm able.

deankarn avatar Jan 07 '19 15:01 deankarn

This seems to be fixed with 9dedb06 so it's safe to close this. I can also open a PR for adding a test case for such a case, but it's already covered by "EXAMPLE" test case

zemzale avatar Jan 17 '22 19:01 zemzale

@ki-ichino-nec Thank you for sharing the original issue. It should now be addressed in the most recent version. Please do not hesitate to follow up if you have any additional questions.

jmvbxx avatar Dec 25 '22 15:12 jmvbxx