From b7da79fd14bfc82d4b902c2ca935e1f0244d1775 Mon Sep 17 00:00:00 2001 From: Phil Estes Date: Mon, 15 Sep 2014 23:30:10 -0400 Subject: [PATCH] Refactor all pre-compiled regexp to package level vars Addresses #8057 Docker-DCO-1.1-Signed-off-by: Phil Estes --- docs/registry.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/registry.go b/docs/registry.go index c773bd57..a2e1fbdd 100644 --- a/docs/registry.go +++ b/docs/registry.go @@ -24,6 +24,8 @@ var ( ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")") errLoginRequired = errors.New("Authentication is required.") validHex = regexp.MustCompile(`^([a-f0-9]{64})$`) + validNamespace = regexp.MustCompile(`^([a-z0-9_]{4,30})$`) + validRepo = regexp.MustCompile(`^([a-z0-9-_.]+)$`) ) type TimeoutType uint32 @@ -216,11 +218,9 @@ func validateRepositoryName(repositoryName string) error { namespace = nameParts[0] name = nameParts[1] } - validNamespace := regexp.MustCompile(`^([a-z0-9_]{4,30})$`) if !validNamespace.MatchString(namespace) { return fmt.Errorf("Invalid namespace name (%s), only [a-z0-9_] are allowed, size between 4 and 30", namespace) } - validRepo := regexp.MustCompile(`^([a-z0-9-_.]+)$`) if !validRepo.MatchString(name) { return fmt.Errorf("Invalid repository name (%s), only [a-z0-9-_.] are allowed", name) }