all: use cmpx.Or where it made sense

I left a few out where writing it explicitly was better
for various reasons.

Updates #8296

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2023-06-07 19:46:59 -07:00
committed by Brad Fitzpatrick
parent 699996ad6c
commit eefee6f149
16 changed files with 35 additions and 69 deletions

View File

@@ -27,6 +27,7 @@ import (
"tailscale.com/net/tsaddr"
"tailscale.com/tsweb/varz"
"tailscale.com/types/logger"
"tailscale.com/util/cmpx"
"tailscale.com/util/vizerror"
)
@@ -144,10 +145,7 @@ func (h Port80Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Redirect authorized user to the debug handler.
path = "/debug/"
}
host := h.FQDN
if host == "" {
host = r.Host
}
host := cmpx.Or(h.FQDN, r.Host)
target := "https://" + host + path
http.Redirect(w, r, target, http.StatusFound)
}