Skip to content

Commit 1a936f5

Browse files
committed
more concise
1 parent ea52e6f commit 1a936f5

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

request/http.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ func (r *Http) SetSecret(secret dmfr.Secret) error {
2727
}
2828

2929
func removeDefaultPortFromHost(req *http.Request) {
30-
if req.URL.Scheme == "https" && strings.HasSuffix(req.URL.Host, ":443") {
31-
host := strings.TrimSuffix(req.URL.Host, ":443")
32-
req.Host = host
33-
} else if req.URL.Scheme == "http" && strings.HasSuffix(req.URL.Host, ":80") {
34-
host := strings.TrimSuffix(req.URL.Host, ":80")
35-
req.Host = host
30+
if (req.URL.Scheme == "https" && strings.HasSuffix(req.URL.Host, ":443")) ||
31+
(req.URL.Scheme == "http" && strings.HasSuffix(req.URL.Host, ":80")) {
32+
req.Host = strings.Split(req.URL.Host, ":")[0]
3633
}
3734
}
3835

0 commit comments

Comments
 (0)