diff --git a/api/project.go b/api/project.go index 073fcdab0..75ba05342 100644 --- a/api/project.go +++ b/api/project.go @@ -18,6 +18,7 @@ package api import ( "fmt" "net/http" + "strings" "unicode" "github.com/vmware/harbor/dao" @@ -294,10 +295,10 @@ func validateProjectReq(req projectReq) error { if isContainIllegalChar(req.ProjectName, []string{"~", "-", "$", "\\", "[", "]", "{", "}", "(", ")", "&", "^", "%", "*", "<", ">", "\"", "'", "/", "?", "@"}) { return fmt.Errorf("project name contains illegal characters") } - for _, v := range pn { - if !unicode.IsLower(v) { - return fmt.Errorf("project name must be in lower case") - } + + if pn != strings.ToLower(pn) { + return fmt.Errorf("project name must be in lower case") } + return nil }