File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change 12
12
usernameReplace = regexp .MustCompile ("[^a-zA-Z0-9-]*" )
13
13
)
14
14
15
+ func UsernameValidRegexString () string {
16
+ return usernameValid .String ()
17
+ }
18
+
15
19
// UsernameValid returns whether the input string is a valid username.
16
20
func UsernameValid (str string ) bool {
17
21
if len (str ) > 32 {
Original file line number Diff line number Diff line change 6
6
"regexp"
7
7
"strings"
8
8
9
+ "github.com/coder/coder/coderd/httpapi"
10
+
9
11
"github.com/coder/coder/coderd/httpmw"
10
12
11
13
"github.com/go-chi/chi/v5"
@@ -70,7 +72,8 @@ func (api *API) handleSubdomain(middlewares ...func(http.Handler) http.Handler)
70
72
}
71
73
72
74
var (
73
- nameRegex = `[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*`
75
+ // Remove the "starts with" and "ends with" regex components.
76
+ nameRegex = strings .Trim (httpapi .UsernameValidRegexString (), "^$" )
74
77
appURL = regexp .MustCompile (fmt .Sprintf (
75
78
// {USERNAME}--{WORKSPACE_NAME}}--{{AGENT_NAME}}--{{PORT}}
76
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