summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/addresses.go
diff options
context:
space:
mode:
authorWilczyƄskiT <102859171+WilczynskiT@users.noreply.github.com>2022-08-04 19:17:35 +0200
committerGitHub <noreply@github.com>2022-08-04 11:17:35 -0600
commit2642bd72b7ca35b8622824fdffced2aefe1aaf11 (patch)
tree3bc73bada610bfee6377eb58d89ca18b72236966 /modules/caddyhttp/reverseproxy/addresses.go
parent17ae5acaba536e98cfa86ddcd6967801f1fa1bbe (diff)
Replace strings.Index usages with strings.Cut (#4930)
Diffstat (limited to 'modules/caddyhttp/reverseproxy/addresses.go')
-rw-r--r--modules/caddyhttp/reverseproxy/addresses.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/caddyhttp/reverseproxy/addresses.go b/modules/caddyhttp/reverseproxy/addresses.go
index f15ed76..c161ed8 100644
--- a/modules/caddyhttp/reverseproxy/addresses.go
+++ b/modules/caddyhttp/reverseproxy/addresses.go
@@ -80,9 +80,9 @@ func parseUpstreamDialAddress(upstreamAddr string) (string, string, error) {
scheme, host, port = toURL.Scheme, toURL.Hostname(), toURL.Port()
} else {
// extract network manually, since caddy.ParseNetworkAddress() will always add one
- if idx := strings.Index(upstreamAddr, "/"); idx >= 0 {
- network = strings.ToLower(strings.TrimSpace(upstreamAddr[:idx]))
- upstreamAddr = upstreamAddr[idx+1:]
+ if beforeSlash, afterSlash, slashFound := strings.Cut(upstreamAddr, "/"); slashFound {
+ network = strings.ToLower(strings.TrimSpace(beforeSlash))
+ upstreamAddr = afterSlash
}
var err error
host, port, err = net.SplitHostPort(upstreamAddr)