mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
@@ -416,6 +416,9 @@ func (s *SiteInfo) refLink(ref string, page *Page, relative bool, outputFormat s
|
|||||||
var refURL *url.URL
|
var refURL *url.URL
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
ref = filepath.ToSlash(ref)
|
||||||
|
ref = strings.TrimPrefix(ref, "/")
|
||||||
|
|
||||||
refURL, err = url.Parse(ref)
|
refURL, err = url.Parse(ref)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -232,6 +232,8 @@ func doTestCrossrefs(t *testing.T, relative, uglyURLs bool) {
|
|||||||
expectedPathSuffix = "/index.html"
|
expectedPathSuffix = "/index.html"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doc3Slashed := filepath.FromSlash("/sect/doc3.md")
|
||||||
|
|
||||||
sources := []source.ByteSource{
|
sources := []source.ByteSource{
|
||||||
{
|
{
|
||||||
Name: filepath.FromSlash("sect/doc1.md"),
|
Name: filepath.FromSlash("sect/doc1.md"),
|
||||||
@@ -251,6 +253,11 @@ THE END.`, refShortcode)),
|
|||||||
Name: filepath.FromSlash("sect/doc3.md"),
|
Name: filepath.FromSlash("sect/doc3.md"),
|
||||||
Content: []byte(fmt.Sprintf(`**Ref 1:**{{< %s "sect/doc3.md" >}}.`, refShortcode)),
|
Content: []byte(fmt.Sprintf(`**Ref 1:**{{< %s "sect/doc3.md" >}}.`, refShortcode)),
|
||||||
},
|
},
|
||||||
|
// Issue #3703
|
||||||
|
{
|
||||||
|
Name: filepath.FromSlash("sect/doc4.md"),
|
||||||
|
Content: []byte(fmt.Sprintf(`**Ref 1:**{{< %s "%s" >}}.`, refShortcode, doc3Slashed)),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, fs := newTestCfg()
|
cfg, fs := newTestCfg()
|
||||||
@@ -271,9 +278,7 @@ THE END.`, refShortcode)),
|
|||||||
WithTemplate: createWithTemplateFromNameValues("_default/single.html", "{{.Content}}")},
|
WithTemplate: createWithTemplateFromNameValues("_default/single.html", "{{.Content}}")},
|
||||||
BuildCfg{})
|
BuildCfg{})
|
||||||
|
|
||||||
if len(s.RegularPages) != 3 {
|
require.Len(t, s.RegularPages, 4)
|
||||||
t.Fatalf("Expected 3 got %d pages", len(s.AllPages))
|
|
||||||
}
|
|
||||||
|
|
||||||
th := testHelper{s.Cfg, s.Fs, t}
|
th := testHelper{s.Cfg, s.Fs, t}
|
||||||
|
|
||||||
@@ -284,6 +289,7 @@ THE END.`, refShortcode)),
|
|||||||
{filepath.FromSlash(fmt.Sprintf("public/sect/doc1%s", expectedPathSuffix)), fmt.Sprintf("<p>Ref 2: %s/sect/doc2%s</p>\n", expectedBase, expectedURLSuffix)},
|
{filepath.FromSlash(fmt.Sprintf("public/sect/doc1%s", expectedPathSuffix)), fmt.Sprintf("<p>Ref 2: %s/sect/doc2%s</p>\n", expectedBase, expectedURLSuffix)},
|
||||||
{filepath.FromSlash(fmt.Sprintf("public/sect/doc2%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong></p>\n\n%s/sect/doc1%s\n\n<p>THE END.</p>\n", expectedBase, expectedURLSuffix)},
|
{filepath.FromSlash(fmt.Sprintf("public/sect/doc2%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong></p>\n\n%s/sect/doc1%s\n\n<p>THE END.</p>\n", expectedBase, expectedURLSuffix)},
|
||||||
{filepath.FromSlash(fmt.Sprintf("public/sect/doc3%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong>%s/sect/doc3%s.</p>\n", expectedBase, expectedURLSuffix)},
|
{filepath.FromSlash(fmt.Sprintf("public/sect/doc3%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong>%s/sect/doc3%s.</p>\n", expectedBase, expectedURLSuffix)},
|
||||||
|
{filepath.FromSlash(fmt.Sprintf("public/sect/doc4%s", expectedPathSuffix)), fmt.Sprintf("<p><strong>Ref 1:</strong>%s/sect/doc3%s.</p>\n", expectedBase, expectedURLSuffix)},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
Reference in New Issue
Block a user