mirror of https://github.com/nmasse-itix/liche.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
613 B
36 lines
613 B
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"io/ioutil"
|
|
"time"
|
|
|
|
"golang.org/x/net/html"
|
|
"gopkg.in/russross/blackfriday.v2"
|
|
)
|
|
|
|
type fileChecker struct {
|
|
urlChecker urlChecker
|
|
}
|
|
|
|
func newFileChecker(timeout time.Duration, verbose bool) fileChecker {
|
|
return fileChecker{newURLChecker(timeout, verbose)}
|
|
}
|
|
|
|
func (c fileChecker) Check(f string) bool {
|
|
bs, err := ioutil.ReadFile(f)
|
|
|
|
if err != nil {
|
|
printToStderr(err.Error())
|
|
return false
|
|
}
|
|
|
|
n, err := html.Parse(bytes.NewReader(blackfriday.Run(bs)))
|
|
|
|
if err != nil {
|
|
printToStderr(err.Error())
|
|
return false
|
|
}
|
|
|
|
return c.urlChecker.CheckMany(extractURLs(n))
|
|
}
|
|
|