Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/internal/helpers/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func ValidateIP(ipaddr string) bool {
// * The exception is IPv6 addresses, which are also permitted.
// * An underscore is allowed to support Docker Swarm service names.
func ValidateHostname(hostname string) bool {
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)
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)

if !matches {
// Try Docker Swarm service name
Expand Down
1 change: 1 addition & 0 deletions core/internal/helpers/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var testHostnames = []TestSet{
{"invalid-docker_-service-name", false},
{"docker-service-may-not-end-with-underscore_", false},
{"_docker-service-may-not-start-with-underscore", false},
{"ends.in.a.dot.", true},
}

func TestValidateHostname(t *testing.T) {
Expand Down
Loading