Skip to content

Commit 770502a

Browse files
authored
Fix removeEmptyPort
remove hasPort and simplify logic
1 parent f22d37d commit 770502a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/net/http/http.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ 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 hasPort(host) {
117-
return strings.TrimSuffix(host, ":")
116+
if len(host) > 0 && host[len(host)-1] == ':' {
117+
return host[:len(host)-1]
118118
}
119119
return host
120120
}

0 commit comments

Comments
 (0)