No leading slash in typical manifests.

This commit is contained in:
Daniel A. Nagy 2016-03-01 16:52:11 +01:00
parent f8c5b3dcee
commit ece9b9f500

View file

@ -54,7 +54,7 @@ func (self *Api) Store(data storage.SectionReader, wg *sync.WaitGroup) (key stor
// DNS Resolver // DNS Resolver
func (self *Api) Resolve(hostPort string, nameresolver bool) (contentHash storage.Key, err error) { func (self *Api) Resolve(hostPort string, nameresolver bool) (contentHash storage.Key, err error) {
if hashMatcher.MatchString(hostPort) || self.dns == nil { 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 return storage.Key(common.Hex2Bytes(hostPort)), nil
} }
if !nameresolver { if !nameresolver {
@ -77,19 +77,17 @@ func parse(uri string) (hostPort, path string) {
return return
} }
// beginning with slash is now optional // beginning with slash is now optional
if len(parts[0]) == 0 { for len(parts[i]) == 0 {
i++ i++
} }
hostPort = parts[i] hostPort = parts[i]
if len(parts) > i+1 { for i < len(parts)-1 {
path = parts[i+1] i++
if len(parts) == 3 { if len(path) > 0 {
path += "/" + parts[2] path = path + "/" + parts[i]
} else {
path = parts[i]
} }
path += "/"
}
if len(path) > 0 {
path = "/" + path
} }
glog.V(logger.Debug).Infof("[BZZ] Swarm: host: '%s', path '%s' requested.", hostPort, path) glog.V(logger.Debug).Infof("[BZZ] Swarm: host: '%s', path '%s' requested.", hostPort, path)
return return
@ -99,6 +97,7 @@ func (self *Api) parseAndResolve(uri string, nameresolver bool) (contentHash sto
hostPort, path = parse(uri) hostPort, path = parse(uri)
//resolving host and port //resolving host and port
contentHash, err = self.Resolve(hostPort, nameresolver) contentHash, err = self.Resolve(hostPort, nameresolver)
glog.V(logger.Debug).Infof("[BZZ] Resolved '%s' to contentHash: '%s', path: '%s'", uri, contentHash, path)
return return
} }