mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
core/config: add support for stripping the port for matching routes (#5085)
* core/config: add support for stripping the port for matching routes * fix test * rename option, improve port detection * add more test cases
This commit is contained in:
parent
498c3aa108
commit
5373e25ac4
14 changed files with 100 additions and 34 deletions
|
@ -106,9 +106,9 @@ func GetServerNamesForURL(u *url.URL) []string {
|
|||
|
||||
// GetDomainsForURL returns the available domains for given url.
|
||||
//
|
||||
// For standard HTTP (80)/HTTPS (443) ports, it returns `example.com` and `example.com:<port>`.
|
||||
// Otherwise, return the URL.Host value.
|
||||
func GetDomainsForURL(u *url.URL) []string {
|
||||
// For standard HTTP (80)/HTTPS (443) ports, it returns `example.com` and `example.com:<port>`,
|
||||
// if includeDefaultPort is set. Otherwise, return the URL.Host value.
|
||||
func GetDomainsForURL(u *url.URL, includeDefaultPort bool) []string {
|
||||
if u == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -141,6 +141,10 @@ func GetDomainsForURL(u *url.URL) []string {
|
|||
}
|
||||
}
|
||||
|
||||
if !includeDefaultPort {
|
||||
return []string{u.Hostname()}
|
||||
}
|
||||
|
||||
// for everything else we return two routes: 'example.com' and 'example.com:443'
|
||||
return []string{u.Hostname(), net.JoinHostPort(u.Hostname(), defaultPort)}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue