Skip to content

Commit 5205034

Browse files
authored
Merge pull request #857 from tomasbanet/hostname-ends-in-a-dot
Support hostnames ending in a dot
2 parents 1ffaa92 + f0123f0 commit 5205034

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

core/internal/helpers/validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func ValidateIP(ipaddr string) bool {
3232
// * The exception is IPv6 addresses, which are also permitted.
3333
// * An underscore is allowed to support Docker Swarm service names.
3434
func ValidateHostname(hostname string) bool {
35-
matches, _ := regexp.MatchString(`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$`, hostname)
35+
matches, _ := regexp.MatchString(`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*\.?$`, hostname)
3636

3737
if !matches {
3838
// Try Docker Swarm service name

core/internal/helpers/validation_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var testHostnames = []TestSet{
5959
{"invalid-docker_-service-name", false},
6060
{"docker-service-may-not-end-with-underscore_", false},
6161
{"_docker-service-may-not-start-with-underscore", false},
62+
{"ends.in.a.dot.", true},
6263
}
6364

6465
func TestValidateHostname(t *testing.T) {

0 commit comments

Comments
 (0)