File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,10 @@ import (
8
8
)
9
9
10
10
var (
11
- usernameValid = regexp .MustCompile ("^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$" )
12
- usernameReplace = regexp .MustCompile ("[^a-zA-Z0-9-]*" )
11
+ UsernameValidRegex = regexp .MustCompile ("^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$" )
12
+ usernameReplace = regexp .MustCompile ("[^a-zA-Z0-9-]*" )
13
13
)
14
14
15
- func UsernameValidRegexString () string {
16
- return usernameValid .String ()
17
- }
18
-
19
15
// UsernameValid returns whether the input string is a valid username.
20
16
func UsernameValid (str string ) bool {
21
17
if len (str ) > 32 {
@@ -24,7 +20,7 @@ func UsernameValid(str string) bool {
24
20
if len (str ) < 1 {
25
21
return false
26
22
}
27
- return usernameValid .MatchString (str )
23
+ return UsernameValidRegex .MatchString (str )
28
24
}
29
25
30
26
// UsernameFrom returns a best-effort username from the provided string.
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ func (api *API) handleSubdomain(middlewares ...func(http.Handler) http.Handler)
73
73
74
74
var (
75
75
// Remove the "starts with" and "ends with" regex components.
76
- nameRegex = strings .Trim (httpapi .UsernameValidRegexString (), "^$" )
76
+ nameRegex = strings .Trim (httpapi .UsernameValidRegex . String (), "^$" )
77
77
appURL = regexp .MustCompile (fmt .Sprintf (
78
78
// {USERNAME}--{WORKSPACE_NAME}}--{{AGENT_NAME}}--{{PORT}}
79
79
`^(?P<UserName>%[1]s)--(?P<WorkspaceName>%[1]s)(--(?P<AgentName>%[1]s))?--(?P<AppName>%[1]s)$` ,
You can’t perform that action at this time.
0 commit comments