Skip to content

Commit

Permalink
tpl/urls: Retain query and fragment with absURL and absLangURL
Browse files Browse the repository at this point in the history
Closes #11772
  • Loading branch information
jmooring authored and bep committed Dec 4, 2023
1 parent 3fc42da commit 9ea7103
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions common/paths/url.go
Expand Up @@ -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, "/")
Expand Down
1 change: 1 addition & 0 deletions common/paths/url_test.go
Expand Up @@ -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 {
Expand Down

0 comments on commit 9ea7103

Please sign in to comment.