Add stripPort helper

This commit is contained in:
Manuel de Brito Fontes 2017-04-24 16:40:23 -03:00
parent 29c849f993
commit 6e30ede516

View file

@ -131,10 +131,22 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
return &External{
URL: str,
Host: ur.Hostname(),
Host: stripPort(ur.Host),
SigninURL: signin,
Method: m,
SendBody: sb,
ResponseHeaders: h,
}, nil
}
// TODO: Remove after upgrade to Go 1.8
func stripPort(hostport string) string {
colon := strings.IndexByte(hostport, ':')
if colon == -1 {
return hostport
}
if i := strings.IndexByte(hostport, ']'); i != -1 {
return strings.TrimPrefix(hostport[:i], "[")
}
return hostport[:colon]
}