addrs: ModuleSourceRemote.String correctly handles query string in URL

Previously it would append the "subdir" portion onto the query string, producing an invalid result.
This commit is contained in:
fatahfattah
2022-08-31 18:13:24 +02:00
committed by GitHub
parent ba113ff2cd
commit 8a31f0a6c8
2 changed files with 66 additions and 2 deletions

View File

@@ -316,10 +316,17 @@ func parseModuleSourceRemote(raw string) (ModuleSourceRemote, error) {
func (s ModuleSourceRemote) moduleSource() {}
func (s ModuleSourceRemote) String() string {
base := s.Package.String()
if s.Subdir != "" {
return s.Package.String() + "//" + s.Subdir
// Address contains query string
if strings.Contains(base, "?") {
parts := strings.SplitN(base, "?", 2)
return parts[0] + "//" + s.Subdir + "?" + parts[1]
}
return base + "//" + s.Subdir
}
return s.Package.String()
return base
}
func (s ModuleSourceRemote) ForDisplay() string {