File tree 1 file changed +16
-16
lines changed
1 file changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -30,25 +30,25 @@ func Glob(pattern, subj string) bool {
30
30
trailingGlob := strings .HasSuffix (pattern , GLOB )
31
31
end := len (parts ) - 1
32
32
33
- // Check the first section. Requires special handling .
34
- if ! leadingGlob {
35
- if strings .HasPrefix (subj , parts [0 ]) {
36
- // Strip prefix, to avoid matching it again
37
- subj = subj [ len ( parts [ 0 ]):]
38
- } else {
39
- return false
40
- }
41
- }
42
-
43
- // Go over the middle parts and ensure they match.
44
- for i := 1 ; i < end ; i ++ {
45
- partStartIdx := strings . Index ( subj , parts [ i ])
46
- if partStartIdx < 0 {
47
- return false
33
+ // Go over the leading parts and ensure they match .
34
+ for i := 0 ; i < end ; i ++ {
35
+ idx := strings .Index (subj , parts [i ])
36
+
37
+ switch i {
38
+ case 0 :
39
+ // Check the first section. Requires special handling.
40
+ if ! leadingGlob && idx != 0 {
41
+ return false
42
+ }
43
+ default :
44
+ // Check that the middle parts match.
45
+ if idx < 0 {
46
+ return false
47
+ }
48
48
}
49
49
50
50
// Trim evaluated text from subj as we loop over the pattern.
51
- subj = subj [partStartIdx + len (parts [i ]):]
51
+ subj = subj [idx + len (parts [i ]):]
52
52
}
53
53
54
54
// Reached the last section. Requires special handling.
You can’t perform that action at this time.
0 commit comments