From 59ff5e02ab3ee5e130c60571fb1f4f52604bbbaa Mon Sep 17 00:00:00 2001 From: cofecatt <60803595+cofecatt@users.noreply.github.com> Date: Tue, 11 Oct 2022 19:39:19 +0800 Subject: [PATCH] fix: Add support for including underscores for username (#1210) * fix: Add support for including underscores for username * Update check.go Co-authored-by: Yang Luo --- object/check.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/object/check.go b/object/check.go index c01c9532..a0261b0b 100644 --- a/object/check.go +++ b/object/check.go @@ -322,11 +322,9 @@ func CheckUsername(name string) string { } // https://stackoverflow.com/questions/58726546/github-username-convention-using-regex - re, _ := regexp.Compile("^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$") + re, _ := regexp.Compile("^[a-zA-Z0-9]+((?:-[a-zA-Z0-9]+)|(?:_[a-zA-Z0-9]+))*$") if !re.MatchString(name) { - return fmt.Sprintf("The name '%s' may only contain alphanumeric characters or hyphens, "+ - "cannot have multiple consecutive hyphens, "+ - "and cannot begin or end with a hyphen.", name) + return "The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline." } return ""