Skip to content

Commit

Permalink
[resolves #23] don't clean-up "//" in paths, patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Jul 21, 2019
1 parent eae5cbd commit 8c5e0ad
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
19 changes: 0 additions & 19 deletions doublestar.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,6 @@ func splitPathOnSeparator(path string, separator rune) (ret []string) {
}
}

// An empty component in the beginning is significant because it indicates an
// absolute path, and an empty component at the end is significant because it
// indicates that the path ended on a path separator. However, empty
// components in the middle are insignificant; they probably indicate a typo
// or a path that was built programmatically without removing duplicate
// separators. We'll remove the inner empty components here...
shift := 0
for i := 1; i < idx-1; i++ {
if ret[i] == "" {
shift++
} else if shift > 0 {
ret[i-shift] = ret[i]
}
}
if shift > 0 {
ret[idx-1-shift] = ret[idx-1]
idx -= shift
}

return ret[:idx]
}

Expand Down
1 change: 1 addition & 0 deletions doublestar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var matchTests = []MatchTest{
{[]string{"*"}, []string{"/"}, false, nil, false},
{[]string{"/*"}, []string{"/"}, true, nil, false},
{[]string{"/*"}, []string{"/debug/"}, false, nil, false},
{[]string{"/*"}, []string{"//"}, false, nil, false},
{[]string{"abc"}, []string{"abc"}, true, nil, true},
{[]string{"*"}, []string{"abc"}, true, nil, true},
{[]string{"*c"}, []string{"abc"}, true, nil, true},
Expand Down

0 comments on commit 8c5e0ad

Please sign in to comment.