mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
resources: Preserve url set in frontmatter without sanitizing
related #6007 (already closed)
This commit is contained in:
parent
18c13adcd4
commit
e4fcb672ed
2 changed files with 17 additions and 6 deletions
|
@ -308,12 +308,16 @@ func CreateTargetPaths(d TargetPathDescriptor) (tp TargetPaths) {
|
||||||
|
|
||||||
linkDir = strings.TrimSuffix(path.Join(slash, linkDir), slash)
|
linkDir = strings.TrimSuffix(path.Join(slash, linkDir), slash)
|
||||||
|
|
||||||
// Note: MakePathSanitized will lower case the path if
|
// if page URL is explicitly set in frontmatter,
|
||||||
// disablePathToLower isn't set.
|
// preserve its value without sanitization
|
||||||
pagePath = d.PathSpec.MakePathSanitized(pagePath)
|
if d.Kind != KindPage || d.URL == "" {
|
||||||
pagePathDir = d.PathSpec.MakePathSanitized(pagePathDir)
|
// Note: MakePathSanitized will lower case the path if
|
||||||
link = d.PathSpec.MakePathSanitized(link)
|
// disablePathToLower isn't set.
|
||||||
linkDir = d.PathSpec.MakePathSanitized(linkDir)
|
pagePath = d.PathSpec.MakePathSanitized(pagePath)
|
||||||
|
pagePathDir = d.PathSpec.MakePathSanitized(pagePathDir)
|
||||||
|
link = d.PathSpec.MakePathSanitized(link)
|
||||||
|
linkDir = d.PathSpec.MakePathSanitized(linkDir)
|
||||||
|
}
|
||||||
|
|
||||||
tp.TargetFilename = filepath.FromSlash(pagePath)
|
tp.TargetFilename = filepath.FromSlash(pagePath)
|
||||||
tp.SubResourceBaseTarget = filepath.FromSlash(pagePathDir)
|
tp.SubResourceBaseTarget = filepath.FromSlash(pagePathDir)
|
||||||
|
|
|
@ -129,6 +129,13 @@ func TestPageTargetPath(t *testing.T) {
|
||||||
BaseName: "mypage",
|
BaseName: "mypage",
|
||||||
URL: "/some/other/path",
|
URL: "/some/other/path",
|
||||||
Type: output.HTMLFormat}, TargetPaths{TargetFilename: "/some/other/path/index.html", SubResourceBaseTarget: "/some/other/path", Link: "/some/other/path/"}},
|
Type: output.HTMLFormat}, TargetPaths{TargetFilename: "/some/other/path/index.html", SubResourceBaseTarget: "/some/other/path", Link: "/some/other/path/"}},
|
||||||
|
{
|
||||||
|
"HTML page with URL containing double hyphen", TargetPathDescriptor{
|
||||||
|
Kind: KindPage,
|
||||||
|
Dir: "/sect/",
|
||||||
|
BaseName: "mypage",
|
||||||
|
URL: "/some/other--url/",
|
||||||
|
Type: output.HTMLFormat}, TargetPaths{TargetFilename: "/some/other--url/index.html", SubResourceBaseTarget: "/some/other--url", Link: "/some/other--url/"}},
|
||||||
{
|
{
|
||||||
"HTML page with expanded permalink", TargetPathDescriptor{
|
"HTML page with expanded permalink", TargetPathDescriptor{
|
||||||
Kind: KindPage,
|
Kind: KindPage,
|
||||||
|
|
Loading…
Reference in a new issue