Skip to content

Commit

Permalink
Make rel links checker more precise. (#85)
Browse files Browse the repository at this point in the history
Co-authored-by: William Bezuidenhout <william.bezuidenhout+github@gmail.com>
  • Loading branch information
jhchabran and burmudar authored May 30, 2022
1 parent d0aac74 commit 8600fc5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"path/filepath"
"strings"
"sync"

Expand Down Expand Up @@ -101,9 +102,9 @@ func (s *Site) checkContentPage(page *contentPageCheckData) (problems []string)
}

if node.Type == blackfriday.Link {
// Require that relative paths link to the actual .md file, so that browsing
// docs on the file system works.
if isPathOnly && u.Path != "" && !strings.HasSuffix(u.Path, ".md") {
// Require that relative paths link to the actual .md file, i.e not the "foo" folder in the case of
// of "foo/index.md", so that browsing docs on the file system works.
if isPathOnly && u.Path != "" && filepath.Ext(u.Path) == "" {
problems = append(problems, fmt.Sprintf("must link to .md file, not %s", u.Path))
}
}
Expand Down

0 comments on commit 8600fc5

Please sign in to comment.