aboutsummaryrefslogtreecommitdiffhomepage
path: root/common/paths
diff options
context:
space:
mode:
authorJoe Mooring <[email protected]>2023-12-01 14:39:09 -0800
committerBjørn Erik Pedersen <[email protected]>2023-12-04 11:41:30 +0100
commit9ea7103db7fb323f1140bb354c2a66d3f8ac5932 (patch)
treee631065d14e3cb63efa8a560b719a428ee5ddaba /common/paths
parent3fc42da3d064873a29144d341ae9bcca5a2d03ca (diff)
downloadhugo-9ea7103db7fb323f1140bb354c2a66d3f8ac5932.tar.gz
hugo-9ea7103db7fb323f1140bb354c2a66d3f8ac5932.zip
tpl/urls: Retain query and fragment with absURL and absLangURL
Closes #11772
Diffstat (limited to 'common/paths')
-rw-r--r--common/paths/url.go2
-rw-r--r--common/paths/url_test.go1
2 files changed, 3 insertions, 0 deletions
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 {