hugolib: Fix ref/relref issue with duplicate base filenames

This commit also makes that function 80x faster.

Fixes #2507
This commit is contained in:
Bjørn Erik Pedersen
2017-05-26 10:12:19 +03:00
parent 50d11138f3
commit 612f6e3afe
4 changed files with 13 additions and 17 deletions

View File

@@ -427,13 +427,7 @@ func (s *SiteInfo) refLink(ref string, page *Page, relative bool, outputFormat s
var link string
if refURL.Path != "" {
for _, page := range s.AllRegularPages {
refPath := filepath.FromSlash(refURL.Path)
if page.Source.Path() == refPath || page.Source.LogicalName() == refPath {
target = page
break
}
}
target := s.getPage(KindPage, refURL.Path)
if target == nil {
return "", fmt.Errorf("No page found with path or logical name \"%s\".\n", refURL.Path)