]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
tpl/urls: Retain query and fragment with absURL and absLangURL
authorJoe Mooring <joe.mooring@veriphor.com>
Fri, 1 Dec 2023 22:39:09 +0000 (14:39 -0800)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 4 Dec 2023 10:41:30 +0000 (11:41 +0100)
Closes #11772

common/paths/url.go
common/paths/url_test.go

index cefefdf11b7b0fdb22c9ba4173c5d0645aaa31b3..093ba9ff7fadc4bf293c4c7fba58ce0700ecec6c 100644 (file)
@@ -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, "/")
index 4e5f7305389c9c7d5d9e9e97c5d6862c148af73e..5a9233c26faa2081e6715015bbb9d774704c1f97 100644 (file)
@@ -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 {