MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / isLoopbackURL

Function isLoopbackURL

internal/server/server_grpc.go:102–113  ·  view source on GitHub ↗
(u string)

Source from the content-addressed store, hash-verified

100}
101
102func isLoopbackURL(u string) bool {
103 // 支持 http://host:port、http://host、https://[::1]:port 等格式
104 for _, scheme := range []string{"https://", "http://"} {
105 u = trimPrefixFold(u, scheme)
106 }
107 host, _, err := net.SplitHostPort(u)
108 if err != nil {
109 // 没有端口号,整个字符串是 host
110 host = u
111 }
112 return host == "localhost" || host == "127.0.0.1" || host == "::1"
113}
114
115func trimPrefixFold(s, prefix string) string {
116 if len(s) >= len(prefix) && s[:len(prefix)] == prefix {

Callers 1

onNodeConnectedFunction · 0.85

Calls 1

trimPrefixFoldFunction · 0.85

Tested by

no test coverage detected