MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / ParseHost

Function ParseHost

internal/caches/utils.go:11–30  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

9)
10
11func ParseHost(key string) string {
12 var schemeIndex = strings.Index(key, "://")
13 if schemeIndex <= 0 {
14 return ""
15 }
16
17 var firstSlashIndex = strings.Index(key[schemeIndex+3:], "/")
18 if firstSlashIndex <= 0 {
19 return ""
20 }
21
22 var host = key[schemeIndex+3 : schemeIndex+3+firstSlashIndex]
23
24 hostPart, _, err := net.SplitHostPort(host)
25 if err == nil && len(hostPart) > 0 {
26 host = configutils.QuoteIP(hostPart)
27 }
28
29 return host
30}

Callers 4

TestParseHostFunction · 0.92
hotLoopMethod · 0.85
AddToListMethod · 0.85
flushItemMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestParseHostFunction · 0.74