capsule
capsule copied to clipboard
fix(webhook) Fix regexp
Thank you for reading my PR.
What?
According to kubernete's DNS validation code here, valid way to validate dns name should be
dnsLabelFormat = `[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?`
dnsSubdomainFormat = fmt.Sprintf(`^%s(?:\.%s)*$`, dnsLabelFormat, dnsLabelFormat)
validWindowsUserDomainDNSRegex = regexp.MustCompile(dnsSubdomainFormat)
I wonder we should remove _
/ should add ending [a-zA-Z0-9]
and more small fixes or not, but in this case I just add heading [a-zA-Z0-9]
to prevent
`.somedns.com`
`-somedns.com`
`_somedns.com`
to be matched.
Or we can just imitate original kubernete code may be.
Any suggestions are welcomed. Thanks.