diff --git a/extensions.go b/extensions.go index 17757ed..4996ea3 100644 --- a/extensions.go +++ b/extensions.go @@ -1,6 +1,9 @@ package main -import "path/filepath" +import ( + "path/filepath" + "strings" +) var extensions = map[string]bool{ ".htm": true, @@ -12,3 +15,7 @@ func isMarkupFile(f string) bool { _, ok := extensions[filepath.Ext(f)] return ok } + +func isHTMLFile(f string) bool { + return strings.HasSuffix(f, ".html") || strings.HasSuffix(f, ".htm") +} diff --git a/extensions_test.go b/extensions_test.go index be29e91..a3314d5 100644 --- a/extensions_test.go +++ b/extensions_test.go @@ -15,3 +15,13 @@ func TestIsMarkupFile(t *testing.T) { assert.False(t, isMarkupFile(f)) } } + +func TestIsHTMLFile(t *testing.T) { + for _, f := range []string{"foo.html", "foo.htm", "foo/bar.html"} { + assert.True(t, isHTMLFile(f)) + } + + for _, f := range []string{"foo", "foo.md", "bar/foo"} { + assert.False(t, isHTMLFile(f)) + } +} diff --git a/file_checker.go b/file_checker.go index 93792cb..3b08546 100644 --- a/file_checker.go +++ b/file_checker.go @@ -4,7 +4,6 @@ import ( "bytes" "io/ioutil" "net/url" - "strings" "sync" "time" @@ -122,7 +121,3 @@ func isURL(s string) bool { u, err := url.Parse(s) return err == nil && (u.Scheme == "" || u.Scheme == "http" || u.Scheme == "https") } - -func isHTMLFile(f string) bool { - return strings.HasSuffix(f, ".html") || strings.HasSuffix(f, ".htm") -}