diff --git a/internal/command/hook_module_install.go b/internal/command/hook_module_install.go index 9971cfbd32e8..4046c7ce5bf0 100644 --- a/internal/command/hook_module_install.go +++ b/internal/command/hook_module_install.go @@ -42,7 +42,9 @@ func (h uiModuleInstallHooks) Install(modulePath string, v *version.Version, loc func (h uiModuleInstallHooks) log(message string) { switch h.View.(type) { case view: - h.View.Log(message) + // there is no unformatted option for the View interface, so we need to + // pass message as a parameter to avoid double escaping % characters + h.View.Log("%s", message) default: h.Ui.Info(message) } diff --git a/internal/getmodules/moduleaddrs/detect_git.go b/internal/getmodules/moduleaddrs/detect_git.go index 353072eb0399..21e9a6f7c15e 100644 --- a/internal/getmodules/moduleaddrs/detect_git.go +++ b/internal/getmodules/moduleaddrs/detect_git.go @@ -40,6 +40,8 @@ func detectGitHub(src string) (string, bool, error) { } if strings.HasPrefix(src, "github.com/") { + src, rawQuery, _ := strings.Cut(src, "?") + parts := strings.Split(src, "/") if len(parts) < 3 { return "", false, fmt.Errorf( @@ -51,6 +53,7 @@ func detectGitHub(src string) (string, bool, error) { if err != nil { return "", true, fmt.Errorf("error parsing GitHub URL: %s", err) } + url.RawQuery = rawQuery if !strings.HasSuffix(url.Path, ".git") { url.Path += ".git" diff --git a/internal/getmodules/moduleaddrs/detect_git_test.go b/internal/getmodules/moduleaddrs/detect_git_test.go index f1a4ba67811a..d78a3a0e23af 100644 --- a/internal/getmodules/moduleaddrs/detect_git_test.go +++ b/internal/getmodules/moduleaddrs/detect_git_test.go @@ -74,6 +74,10 @@ func TestDetectGitHub(t *testing.T) { "github.com/hashicorp/foo.git?foo=bar", "git::https://github.com/hashicorp/foo.git?foo=bar", }, + { + "github.com/hashicorp/foo.git?foo=bar/baz", + "git::https://github.com/hashicorp/foo.git?foo=bar/baz", + }, }) }