refactor: build application URL (#9601)

* refactor: build application URL

* fix
This commit is contained in:
Marcin Tojek
2023-09-08 16:01:57 +02:00
committed by GitHub
parent 392b11272b
commit ad23075e1b
6 changed files with 53 additions and 25 deletions

View File

@ -31,7 +31,15 @@ type ApplicationURL struct {
// String returns the application URL hostname without scheme. You will likely
// want to append a period and the base hostname.
func (a ApplicationURL) String() string {
return fmt.Sprintf("%s--%s--%s--%s", a.AppSlugOrPort, a.AgentName, a.WorkspaceName, a.Username)
var appURL strings.Builder
_, _ = appURL.WriteString(a.AppSlugOrPort)
_, _ = appURL.WriteString("--")
_, _ = appURL.WriteString(a.AgentName)
_, _ = appURL.WriteString("--")
_, _ = appURL.WriteString(a.WorkspaceName)
_, _ = appURL.WriteString("--")
_, _ = appURL.WriteString(a.Username)
return appURL.String()
}
// ParseSubdomainAppURL parses an ApplicationURL from the given subdomain. If