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)
| 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. |
| 43 | func 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. |
| 61 | type ApplicationURL struct { |
no test coverage detected