fix(capitalize package):

deal with special package name
fix #29
pull/34/head
hxzhao527 2018-12-27 20:05:31 +08:00 committed by kun
parent 98338ce2aa
commit 4e4281e131
1 changed files with 13 additions and 1 deletions

View File

@ -85,6 +85,7 @@ func NewProxy(cache string) http.Handler {
func parseModInfoFromUrl(url string) (*modInfo, error) {
var modPath, modVersion, suf string
var err error
switch {
case strings.HasSuffix(url, "/@v/list"):
// /golang.org/x/net/@v/list
@ -105,11 +106,22 @@ func parseModInfoFromUrl(url string) (*modInfo, error) {
if len(tmp) != 2 {
return nil, fmt.Errorf("bad module path:%s", url)
}
modVersion = strings.TrimSuffix(tmp[1], ext)
modPath = strings.Trim(tmp[0], "/")
modVersion = strings.TrimSuffix(tmp[1], ext)
modVersion, err = module.DecodeVersion(modVersion)
if err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("bad module path:%s", url)
}
// decode path & version, next proxy and source need
modPath, err = module.DecodePath(modPath)
if err != nil {
return nil, err
}
return &modInfo{module.Version{Path: modPath, Version: modVersion}, suf}, nil
}