Browse Source

Move isHTMLFile function

renovate/configure
Yota Toyama 8 years ago
parent
commit
546bd16aba
  1. 9
      extensions.go
  2. 10
      extensions_test.go
  3. 5
      file_checker.go

9
extensions.go

@ -1,6 +1,9 @@
package main package main
import "path/filepath" import (
"path/filepath"
"strings"
)
var extensions = map[string]bool{ var extensions = map[string]bool{
".htm": true, ".htm": true,
@ -12,3 +15,7 @@ func isMarkupFile(f string) bool {
_, ok := extensions[filepath.Ext(f)] _, ok := extensions[filepath.Ext(f)]
return ok return ok
} }
func isHTMLFile(f string) bool {
return strings.HasSuffix(f, ".html") || strings.HasSuffix(f, ".htm")
}

10
extensions_test.go

@ -15,3 +15,13 @@ func TestIsMarkupFile(t *testing.T) {
assert.False(t, isMarkupFile(f)) 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))
}
}

5
file_checker.go

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"io/ioutil" "io/ioutil"
"net/url" "net/url"
"strings"
"sync" "sync"
"time" "time"
@ -122,7 +121,3 @@ func isURL(s string) bool {
u, err := url.Parse(s) u, err := url.Parse(s)
return err == nil && (u.Scheme == "" || u.Scheme == "http" || u.Scheme == "https") 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")
}

Loading…
Cancel
Save