look for absolute links to docs.docker.com

Signed-off-by: Adrien Duermael <adrien@duermael.com>
This commit is contained in:
Adrien Duermael
2016-12-13 13:15:18 -08:00
parent 15e07d63fc
commit 39ea6e4286

View File

@@ -66,44 +66,38 @@ func testURLs(htmlBytes []byte) error {
return nil
case html.StartTagToken:
t := z.Token()
url := ""
// check tag types
switch t.Data {
case "a":
countLinks++
ok, _ := getHref(t)
ok, href := getHref(t)
// skip, it may just be an anchor
if !ok {
break
}
url = href
case "img":
countImages++
ok, _ := getSrc(t)
ok, src := getSrc(t)
if !ok {
return errors.New("img with no src: " + t.String())
}
url = src
}
// there's an url to test!
if url != "" {
if strings.Contains(url, "docs.docker.com") {
return errors.New("found absolute link: " + t.String())
}
}
}
}
// _, md, err := frontparser.ParseFrontmatterAndContent(mdBytes)
// if err != nil {
// return err
// }
// regularExpression, err := regexp.Compile(`\[[^\]]+\]\(([^\)]+)\)`)
// if err != nil {
// return err
// }
// submatches := regularExpression.FindAllStringSubmatch(string(md), -1)
// for _, submatch := range submatches {
// if strings.Contains(submatch[1], "docs.docker.com") {
// return errors.New("found absolute link (" + strings.TrimSpace(submatch[1]) + ")")
// }
// }
return nil
}