@@ -21,6 +21,7 @@ import (
21
21
"cdr.dev/slog/sloggers/slogtest"
22
22
"github.com/coder/coder/v2/agent"
23
23
"github.com/coder/coder/v2/coderd/coderdtest"
24
+ "github.com/coder/coder/v2/coderd/httpapi"
24
25
"github.com/coder/coder/v2/coderd/workspaceapps"
25
26
"github.com/coder/coder/v2/codersdk"
26
27
"github.com/coder/coder/v2/codersdk/agentsdk"
@@ -141,10 +142,14 @@ func (d *Details) PathAppURL(app App) *url.URL {
141
142
142
143
// SubdomainAppURL returns the URL for the given subdomain app.
143
144
func (d * Details ) SubdomainAppURL (app App ) * url.URL {
144
- host := fmt .Sprintf ("%s--%s--%s--%s" , app .AppSlugOrPort , app .AgentName , app .WorkspaceName , app .Username )
145
-
145
+ appHost := httpapi.ApplicationURL {
146
+ AppSlugOrPort : app .AppSlugOrPort ,
147
+ AgentName : app .AgentName ,
148
+ WorkspaceName : app .WorkspaceName ,
149
+ Username : app .Username ,
150
+ }
146
151
u := * d .PathAppBaseURL
147
- u .Host = strings .Replace (d .Options .AppHost , "*" , host , 1 )
152
+ u .Host = strings .Replace (d .Options .AppHost , "*" , appHost . String () , 1 )
148
153
u .Path = "/"
149
154
u .RawQuery = app .Query
150
155
return & u
@@ -355,13 +360,14 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
355
360
if primaryAppHost .Host != "" {
356
361
manifest , err := agentClient .Manifest (appHostCtx )
357
362
require .NoError (t , err )
358
- proxyURL := fmt .Sprintf (
359
- "http://{{port}}--%s--%s--%s%s" ,
360
- proxyTestAgentName ,
361
- workspace .Name ,
362
- me .Username ,
363
- strings .ReplaceAll (primaryAppHost .Host , "*" , "" ),
364
- )
363
+
364
+ appHost := httpapi.ApplicationURL {
365
+ AppSlugOrPort : "{{port}}" ,
366
+ AgentName : proxyTestAgentName ,
367
+ WorkspaceName : workspace .Name ,
368
+ Username : me .Username ,
369
+ }
370
+ proxyURL := "http://" + appHost .String () + strings .ReplaceAll (primaryAppHost .Host , "*" , "" )
365
371
require .Equal (t , proxyURL , manifest .VSCodePortProxyURI )
366
372
}
367
373
agentCloser := agent .New (agent.Options {
0 commit comments