MCPcopy Create free account
hub / github.com/rilldata/rill / WithCustomDomainFromRedirectURL

Method WithCustomDomainFromRedirectURL

admin/urls.go:116–134  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
116func (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.
137func (u *URLs) IsHTTPS() bool {

Callers 1

authLoginCallbackMethod · 0.80

Calls 2

WithCustomDomainMethod · 0.95
ParseMethod · 0.80

Tested by

no test coverage detected