diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2019-02-07 18:50:16 -0500 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2019-02-07 18:50:16 -0500 |
| commit | 0bcd783a71a57212bee74c0adf31b0f8adc67eea (patch) | |
| tree | 4f3565804078e0d4c39da57cb41518ab7c3171bb /vendor/github.com/ryanuber | |
| parent | 8a13b82081d98e7c425251daf0c4f58d363107e1 (diff) | |
Updating deps
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'vendor/github.com/ryanuber')
| -rw-r--r-- | vendor/github.com/ryanuber/go-glob/glob.go | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/vendor/github.com/ryanuber/go-glob/glob.go b/vendor/github.com/ryanuber/go-glob/glob.go index d9d46379..e67db3be 100644 --- a/vendor/github.com/ryanuber/go-glob/glob.go +++ b/vendor/github.com/ryanuber/go-glob/glob.go @@ -30,20 +30,25 @@ func Glob(pattern, subj string) bool { trailingGlob := strings.HasSuffix(pattern, GLOB) end := len(parts) - 1 - // Check the first section. Requires special handling. - if !leadingGlob && !strings.HasPrefix(subj, parts[0]) { - return false - } - - // Go over the middle parts and ensure they match. - for i := 1; i < end; i++ { - if !strings.Contains(subj, parts[i]) { - return false + // Go over the leading parts and ensure they match. + for i := 0; i < end; i++ { + idx := strings.Index(subj, parts[i]) + + switch i { + case 0: + // Check the first section. Requires special handling. + if !leadingGlob && idx != 0 { + return false + } + default: + // Check that the middle parts match. + if idx < 0 { + return false + } } // Trim evaluated text from subj as we loop over the pattern. - idx := strings.Index(subj, parts[i]) + len(parts[i]) - subj = subj[idx:] + subj = subj[idx+len(parts[i]):] } // Reached the last section. Requires special handling. |
