WithCustomDomainFromRedirectURL attempts to infer a custom domain from a redirect URL. If it succeeds, it passes the custom domain to WithCustomDomain and returns the result. If it does not detect a custom domain in the redirect URL, or the redirect URL is invalid, it fails silently by returning its
(redirectURL string)
| 114 | // If it succeeds, it passes the custom domain to WithCustomDomain and returns the result. |
| 115 | // If it does not detect a custom domain in the redirect URL, or the redirect URL is invalid, it fails silently by returning itself unchanged. |
| 116 | func (u *URLs) WithCustomDomainFromRedirectURL(redirectURL string) *URLs { |
| 117 | u2, err := url.Parse(redirectURL) |
| 118 | if err != nil { |
| 119 | // Ignoring err as per docstring. |
| 120 | return u |
| 121 | } |
| 122 | |
| 123 | // Skip if there's no host in the redirect URL. |
| 124 | if u2.Host == "" { |
| 125 | return u |
| 126 | } |
| 127 | |
| 128 | // Skip if it points to the primary external or frontend URL. |
| 129 | if strings.HasPrefix(redirectURL, u.external) || strings.HasPrefix(redirectURL, u.frontend) { |
| 130 | return u |
| 131 | } |
| 132 | |
| 133 | return u.WithCustomDomain(u2.Host) |
| 134 | } |
| 135 | |
| 136 | // IsHTTPS returns true if the admin service's external URL uses HTTPS. |
| 137 | func (u *URLs) IsHTTPS() bool { |
no test coverage detected