MCPcopy Index your code
hub / github.com/coder/coder / SubdomainAppHost

Function SubdomainAppHost

coderd/workspaceapps/appurl/appurl.go:43–58  ·  view source on GitHub ↗

SubdomainAppHost returns the URL of the apphost for subdomain based apps. It will omit the scheme. Arguments: apphost: Expected to contain a wildcard, example: "*.coder.com" accessURL: The access url for the deployment. Returns: 'apphost:port' For backwards compatibility and for "accessurl=localh

(apphost string, accessURL *url.URL)

Source from the content-addressed store, hash-verified

41// to use the port from the accessurl if the apphost doesn't have a port.
42// If the user specifies a port in the apphost, we will use that port instead.
43func SubdomainAppHost(apphost string, accessURL *url.URL) string {
44 if apphost == "" {
45 return ""
46 }
47
48 if apphost != "" && accessURL.Port() != "" {
49 // This should always parse if we prepend a scheme. We should add
50 // the access url port if the apphost doesn't have a port specified.
51 appHostU, err := url.Parse(fmt.Sprintf("https://%s", apphost))
52 if err != nil || (err == nil && appHostU.Port() == "") {
53 apphost += fmt.Sprintf(":%s", accessURL.Port())
54 }
55 }
56
57 return apphost
58}
59
60// ApplicationURL is a parsed application URL hostname.
61type ApplicationURL struct {

Callers 3

PrimaryRegionMethod · 0.92
appHostMethod · 0.92
vscodeProxyURIFunction · 0.92

Calls 1

ParseMethod · 0.65

Tested by

no test coverage detected