WithCustomDomain returns a copy that generates URLs for the provided custom domain (as described in the type doc). The result automatically generates correct URLs also for the few endpoints that must always use the non-custom external URL (such as AuthLogin).
(domain string)
| 55 | // WithCustomDomain returns a copy that generates URLs for the provided custom domain (as described in the type doc). |
| 56 | // The result automatically generates correct URLs also for the few endpoints that must always use the non-custom external URL (such as AuthLogin). |
| 57 | func (u *URLs) WithCustomDomain(domain string) *URLs { |
| 58 | if u.custom != "" { |
| 59 | panic(fmt.Errorf("nested calls to WithCustomDomain are not allowed")) |
| 60 | } |
| 61 | |
| 62 | if domain == "" { |
| 63 | return u |
| 64 | } |
| 65 | |
| 66 | custom := &url.URL{ |
| 67 | Scheme: "https", |
| 68 | Host: domain, |
| 69 | } |
| 70 | if !u.https { |
| 71 | custom.Scheme = "http" |
| 72 | } |
| 73 | |
| 74 | return &URLs{ |
| 75 | external: u.external, |
| 76 | frontend: u.frontend, |
| 77 | custom: custom.String(), |
| 78 | https: u.https, |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | // IsSafeRedirectURL reports whether redirect is safe to redirect to after an auth flow. |
| 83 | // A redirect is safe when it is: |
no test coverage detected