Skip to content

Commit 49bf2d7

Browse files
tklausergopherbot
authored andcommitted
proxy: use strings.TrimSuffix
Change-Id: Icca4cdbdc1fb964eda8e0fed559f8d4e5dc45073 Reviewed-on: https://go-review.googlesource.com/c/net/+/586115 Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Tobias Klauser <[email protected]> Reviewed-by: Carlos Amedee <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent c87a5b6 commit 49bf2d7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

proxy/per_host.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ func (p *PerHost) AddNetwork(net *net.IPNet) {
137137
// AddZone specifies a DNS suffix that will use the bypass proxy. A zone of
138138
// "example.com" matches "example.com" and all of its subdomains.
139139
func (p *PerHost) AddZone(zone string) {
140-
if strings.HasSuffix(zone, ".") {
141-
zone = zone[:len(zone)-1]
142-
}
140+
zone = strings.TrimSuffix(zone, ".")
143141
if !strings.HasPrefix(zone, ".") {
144142
zone = "." + zone
145143
}
@@ -148,8 +146,6 @@ func (p *PerHost) AddZone(zone string) {
148146

149147
// AddHost specifies a host name that will use the bypass proxy.
150148
func (p *PerHost) AddHost(host string) {
151-
if strings.HasSuffix(host, ".") {
152-
host = host[:len(host)-1]
153-
}
149+
host = strings.TrimSuffix(host, ".")
154150
p.bypassHosts = append(p.bypassHosts, host)
155151
}

0 commit comments

Comments
 (0)