From 9ea7103db7fb323f1140bb354c2a66d3f8ac5932 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Fri, 1 Dec 2023 14:39:09 -0800 Subject: [PATCH] tpl/urls: Retain 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 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 {