diff --git a/internal/mailer/templatemailer/templatemailer.go b/internal/mailer/templatemailer/templatemailer.go index 05726baad..f1c2f2b56 100644 --- a/internal/mailer/templatemailer/templatemailer.go +++ b/internal/mailer/templatemailer/templatemailer.go @@ -465,6 +465,12 @@ func getPath(filepath string, params *emailParams) (*url.URL, error) { } if params != nil { path.RawQuery = fmt.Sprintf("token=%s&type=%s&redirect_to=%s", url.QueryEscape(params.Token), url.QueryEscape(params.Type), encodeRedirectURL(params.RedirectTo)) + + // If the path already has query params, append them + q := path.Query().Encode() + if q != "" { + path.RawQuery += fmt.Sprintf("&%s", q) + } } return path, nil } diff --git a/internal/mailer/templatemailer/templatemailer_url_test.go b/internal/mailer/templatemailer/templatemailer_url_test.go index 672d37130..074013cb1 100644 --- a/internal/mailer/templatemailer/templatemailer_url_test.go +++ b/internal/mailer/templatemailer/templatemailer_url_test.go @@ -56,6 +56,12 @@ func TestGetPath(t *testing.T) { Params: ¶ms, Expected: "https://test.example.com?token=token&type=signup&redirect_to=https://example.com", }, + { + SiteURL: "https://test.example.com/", + Path: "/trailingslash?flow=test", + Params: ¶ms, + Expected: "https://test.example.com/trailingslash?token=token&type=signup&redirect_to=https://example.com&flow=test", + }, } for _, c := range cases {