diff --git a/fs/filter/filter.go b/fs/filter/filter.go index 0efd46aa7..ef2a21c3a 100644 --- a/fs/filter/filter.go +++ b/fs/filter/filter.go @@ -254,7 +254,7 @@ func (f *Filter) addDirGlobs(Include bool, glob string) error { if dirGlob == "/" { continue } - dirRe, err := globToRegexp(dirGlob, f.Opt.IgnoreCase) + dirRe, err := GlobToRegexp(dirGlob, f.Opt.IgnoreCase) if err != nil { return err } @@ -274,7 +274,7 @@ func (f *Filter) Add(Include bool, glob string) error { if strings.Contains(glob, "**") { isDirRule, isFileRule = true, true } - re, err := globToRegexp(glob, f.Opt.IgnoreCase) + re, err := GlobToRegexp(glob, f.Opt.IgnoreCase) if err != nil { return err } diff --git a/fs/filter/glob.go b/fs/filter/glob.go index 96a48d3d4..f9198a886 100644 --- a/fs/filter/glob.go +++ b/fs/filter/glob.go @@ -10,10 +10,10 @@ import ( "github.com/pkg/errors" ) -// globToRegexp converts an rsync style glob to a regexp +// GlobToRegexp converts an rsync style glob to a regexp // // documented in filtering.md -func globToRegexp(glob string, ignoreCase bool) (*regexp.Regexp, error) { +func GlobToRegexp(glob string, ignoreCase bool) (*regexp.Regexp, error) { var re bytes.Buffer if ignoreCase { _, _ = re.WriteString("(?i)") diff --git a/fs/filter/glob_test.go b/fs/filter/glob_test.go index 008d4bfd3..351f93321 100644 --- a/fs/filter/glob_test.go +++ b/fs/filter/glob_test.go @@ -42,7 +42,7 @@ func TestGlobToRegexp(t *testing.T) { {`a\\b`, `(^|/)a\\b$`, ``}, } { for _, ignoreCase := range []bool{false, true} { - gotRe, err := globToRegexp(test.in, ignoreCase) + gotRe, err := GlobToRegexp(test.in, ignoreCase) if test.error == "" { prefix := "" if ignoreCase { @@ -102,7 +102,7 @@ func TestGlobToDirGlobs(t *testing.T) { {"/sausage3**", []string{`/sausage3**/`, "/"}}, {"/a/*.jpg", []string{`/a/`, "/"}}, } { - _, err := globToRegexp(test.in, false) + _, err := GlobToRegexp(test.in, false) assert.NoError(t, err) got := globToDirGlobs(test.in) assert.Equal(t, test.want, got, test.in)