mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
No leading slash in typical manifests.
This commit is contained in:
parent
f8c5b3dcee
commit
ece9b9f500
1 changed files with 9 additions and 10 deletions
|
|
@ -54,7 +54,7 @@ func (self *Api) Store(data storage.SectionReader, wg *sync.WaitGroup) (key stor
|
|||
// DNS Resolver
|
||||
func (self *Api) Resolve(hostPort string, nameresolver bool) (contentHash storage.Key, err error) {
|
||||
if hashMatcher.MatchString(hostPort) || self.dns == nil {
|
||||
glog.V(logger.Debug).Infof("[BZZ] host is a contentHash: '%v'", contentHash)
|
||||
glog.V(logger.Debug).Infof("[BZZ] host is a contentHash: '%v'", hostPort)
|
||||
return storage.Key(common.Hex2Bytes(hostPort)), nil
|
||||
}
|
||||
if !nameresolver {
|
||||
|
|
@ -77,19 +77,17 @@ func parse(uri string) (hostPort, path string) {
|
|||
return
|
||||
}
|
||||
// beginning with slash is now optional
|
||||
if len(parts[0]) == 0 {
|
||||
for len(parts[i]) == 0 {
|
||||
i++
|
||||
}
|
||||
hostPort = parts[i]
|
||||
if len(parts) > i+1 {
|
||||
path = parts[i+1]
|
||||
if len(parts) == 3 {
|
||||
path += "/" + parts[2]
|
||||
}
|
||||
path += "/"
|
||||
}
|
||||
for i < len(parts)-1 {
|
||||
i++
|
||||
if len(path) > 0 {
|
||||
path = "/" + path
|
||||
path = path + "/" + parts[i]
|
||||
} else {
|
||||
path = parts[i]
|
||||
}
|
||||
}
|
||||
glog.V(logger.Debug).Infof("[BZZ] Swarm: host: '%s', path '%s' requested.", hostPort, path)
|
||||
return
|
||||
|
|
@ -99,6 +97,7 @@ func (self *Api) parseAndResolve(uri string, nameresolver bool) (contentHash sto
|
|||
hostPort, path = parse(uri)
|
||||
//resolving host and port
|
||||
contentHash, err = self.Resolve(hostPort, nameresolver)
|
||||
glog.V(logger.Debug).Infof("[BZZ] Resolved '%s' to contentHash: '%s', path: '%s'", uri, contentHash, path)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue