diff --git a/parsers/golang/dep.go b/parsers/golang/dep.go index 85a3f39..0d80f6e 100644 --- a/parsers/golang/dep.go +++ b/parsers/golang/dep.go @@ -83,6 +83,14 @@ func (gp *golangParser) getDependenciesFromDep(pkgPath string) []*structs.Depend Version: dep.Version, } + // Name is used in URLs composing, so we should get rid of + // possible versioning from it, which will occur if dependency + // supports both go modules and other dependency managers. + depName := strings.Split(dependency.Name, "/") + if strings.HasPrefix(depName[len(depName)-1], "v") && len(depName[len(depName)-1]) == 2 { + dependency.Name = strings.Join(depName[:len(depName)-1], "/") + } + // If branch is empty - assume master. if dependency.VCS.Branch == "" { dependency.VCS.Branch = "master" diff --git a/parsers/golang/modules.go b/parsers/golang/modules.go index 11ee1e0..2a33701 100644 --- a/parsers/golang/modules.go +++ b/parsers/golang/modules.go @@ -93,6 +93,14 @@ func (gp *golangParser) getDependenciesFromModules(pkgPath string) []*structs.De Version: version, } + // Name is used in URLs composing, so we should get rid of + // possible versioning from it, which will occur if dependency + // supports both go modules and other dependency managers. + depName := strings.Split(dependency.Name, "/") + if strings.HasPrefix(depName[len(depName)-1], "v") && len(depName[len(depName)-1]) == 2 { + dependency.Name = strings.Join(depName[:len(depName)-1], "/") + } + deps = append(deps, dependency) // Mark dependency as processed.