From 8d90def103ca8487c98bbca33d8ca6331aa75693 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Fri, 1 Dec 2023 14:39:09 -0800 Subject: [PATCH] tpl/urls: Retail query and fragment with absURL and absLangURL Closes #11772 --- common/paths/url.go | 2 ++ common/paths/url_test.go | 1 + 2 files changed, 3 insertions(+) diff --git a/common/paths/url.go b/common/paths/url.go index cefefdf11b7..093ba9ff7fa 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 4e5f7305389..5a9233c26fa 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 {