1 Star 0 Fork 0

docker-mirror / distribution

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
addr.go 703 Bytes
一键复制 编辑 原始数据 按行查看 历史
lilongyu 提交于 2020-10-09 11:10 . Initial commit
package challenge
import (
"net/url"
"strings"
)
// FROM: https://golang.org/src/net/http/http.go
// Given a string of the form "host", "host:port", or "[ipv6::address]:port",
// return true if the string includes a port.
func hasPort(s string) bool { return strings.LastIndex(s, ":") > strings.LastIndex(s, "]") }
// FROM: http://golang.org/src/net/http/transport.go
var portMap = map[string]string{
"http": "80",
"https": "443",
}
// canonicalAddr returns url.Host but always with a ":port" suffix
// FROM: http://golang.org/src/net/http/transport.go
func canonicalAddr(url *url.URL) string {
addr := url.Host
if !hasPort(addr) {
return addr + ":" + portMap[url.Scheme]
}
return addr
}
1
https://gitee.com/docker-mirror/distribution.git
git@gitee.com:docker-mirror/distribution.git
docker-mirror
distribution
distribution
ccecc01c46a5

搜索帮助

53164aa7 5694891 3bd8fe86 5694891