Skip to content

Commit

Permalink
edit: edit server_test.go
Browse files Browse the repository at this point in the history
正则字符串使用``处理,避免转义字符
  • Loading branch information
Zherphy committed Dec 12, 2024
1 parent 474ed09 commit 55741c8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ func Test_server_dealWithAuthError(t *testing.T) {
w http.ResponseWriter
r *http.Request
}
validatecfg.passwordRegexp, _ = regexp.Compile("^[a-zA-Z0-9!@_#$%^&*()\\-=+,?.,]*$")
validatecfg.usernameRegexp, _ = regexp.Compile("^[a-zA-Z]([-_.]?[a-zA-Z0-9]+)*$")
validatecfg.passwordRegexp, _ = regexp.Compile(`^[a-zA-Z0-9!@_#$%^&*()-=+,?.,]*$`)
validatecfg.usernameRegexp, _ = regexp.Compile(`^[a-zA-Z]([-_.]?[a-zA-Z0-9]+)*$`)
username := "user"
password := "wrong_pwd"
authString := fmt.Sprintf("%s:%s", username, password)
Expand Down Expand Up @@ -487,8 +487,8 @@ func Test_server_handleBatch(t *testing.T) {
req = req.WithContext(context.WithValue(req.Context(), chi.RouteCtxKey, ctx))
ctx.URLParams.Add("owner", owner)
ctx.URLParams.Add("repo", repo)
validatecfg.ownerRegexp, _ = regexp.Compile("^[a-zA-Z]([-_.]?[a-zA-Z0-9]+)*$")
validatecfg.reponameRegexp, _ = regexp.Compile("^[a-zA-Z0-9_.-]{1,189}[a-zA-Z0-9]$")
validatecfg.ownerRegexp, _ = regexp.Compile(`^[a-zA-Z]([-_.]?[a-zA-Z0-9]+)*$`)
validatecfg.reponameRegexp, _ = regexp.Compile(`^[a-zA-Z0-9_.-]{1,189}[a-zA-Z0-9]$`)
tests := []struct {
name string
fields ServerInfo
Expand Down

0 comments on commit 55741c8

Please sign in to comment.