From: Joe Mooring Date: Fri, 1 Dec 2023 22:39:09 +0000 (-0800) Subject: tpl/urls: Retain query and fragment with absURL and absLangURL X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=9ea7103db;p=brevno-suite%2Fhugo tpl/urls: Retain query and fragment with absURL and absLangURL Closes #11772 --- diff --git a/common/paths/url.go b/common/paths/url.go index cefefdf11..093ba9ff7 100644 --- a/common/paths/url.go +++ b/common/paths/url.go @@ -71,6 +71,8 @@ func MakePermalink(host, plink string) *url.URL { } base.Path = path.Join(base.Path, p.Path) + base.Fragment = p.Fragment + base.RawQuery = p.RawQuery // path.Join will strip off the last /, so put it back if it was there. hadTrailingSlash := (plink == "" && strings.HasSuffix(host, "/")) || strings.HasSuffix(p.Path, "/") diff --git a/common/paths/url_test.go b/common/paths/url_test.go index 4e5f73053..5a9233c26 100644 --- a/common/paths/url_test.go +++ b/common/paths/url_test.go @@ -31,6 +31,7 @@ func TestMakePermalink(t *testing.T) { {"http://abc.com", "bar", "http://abc.com/bar"}, {"http://abc.com/foo/bar", "post/bar", "http://abc.com/foo/bar/post/bar"}, {"http://abc.com/foo/bar", "post/bar/", "http://abc.com/foo/bar/post/bar/"}, + {"http://abc.com/foo", "post/bar?a=b#c", "http://abc.com/foo/post/bar?a=b#c"}, } for i, d := range data {