Skip to content

Commit 2eb154b

Browse files
authored
Simplify removeEmptyPort function implementation
1 parent 770502a commit 2eb154b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/net/http/http.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ func hasPort(s string) bool { return strings.LastIndex(s, ":") > strings.LastInd
113113
// removeEmptyPort strips the empty port in ":port" to ""
114114
// as mandated by RFC 3986 Section 6.2.3.
115115
func removeEmptyPort(host string) string {
116-
if len(host) > 0 && host[len(host)-1] == ':' {
117-
return host[:len(host)-1]
118-
}
116+
host, _ = strings.CutSuffix(host, ":")
119117
return host
120118
}
121119

0 commit comments

Comments
 (0)