mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
feat: remove agent name from app URLs (#19750)
## Summary In this pull request we're removing `agent_name` from subdomains in APP urls when an `app` is used in the subdomain. `agent_names` will still be used when a `port` is used in the subdomain. Closes: https://github.com/coder/coder/issues/18485 ### Changes - Updated regex to support an optional agent name - Added logic to support checking the app slug for a matching port (e.g., 8080 or 8080s) ### Testing - Updated all tests to support an optional `agent_name`
This commit is contained in:
@@ -532,13 +532,20 @@ func AppSubdomain(dbApp database.WorkspaceApp, agentName, workspaceName, ownerNa
|
||||
if appSlug == "" {
|
||||
appSlug = dbApp.DisplayName
|
||||
}
|
||||
|
||||
// Agent name is optional when app slug is present
|
||||
normalizedAgentName := agentName
|
||||
if !appurl.PortRegex.MatchString(appSlug) {
|
||||
normalizedAgentName = ""
|
||||
}
|
||||
|
||||
return appurl.ApplicationURL{
|
||||
// We never generate URLs with a prefix. We only allow prefixes when
|
||||
// parsing URLs from the hostname. Users that want this feature can
|
||||
// write out their own URLs.
|
||||
Prefix: "",
|
||||
AppSlugOrPort: appSlug,
|
||||
AgentName: agentName,
|
||||
AgentName: normalizedAgentName,
|
||||
WorkspaceName: workspaceName,
|
||||
Username: ownerName,
|
||||
}.String()
|
||||
|
||||
Reference in New Issue
Block a user