Skip to content

Commit

Permalink
Skip additional validations
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemassa authored and bmatcuk committed Jan 25, 2025
1 parent 24bdb14 commit 3b1e3d1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions match.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ MATCH:
// we've reached the end of `name`; we've successfully matched if we've also
// reached the end of `pattern`, or if the rest of `pattern` can match a
// zero-length string
return isZeroLengthPattern(pattern[patIdx:], separator)
return isZeroLengthPattern(pattern[patIdx:], separator, validate)
}

func isZeroLengthPattern(pattern string, separator rune) (ret bool, err error) {
func isZeroLengthPattern(pattern string, separator rune, validate bool) (ret bool, err error) {
// `/**`, `**/`, and `/**/` are special cases - a pattern such as `path/to/a/**` or `path/to/a/**/`
// *should* match `path/to/a` because `a` might be a directory
if pattern == "" ||
Expand Down Expand Up @@ -350,18 +350,18 @@ func isZeroLengthPattern(pattern string, separator rune) (ret bool, err error) {
}
commaIdx += patIdx

ret, err = isZeroLengthPattern(pattern[patIdx:commaIdx]+pattern[closingIdx+1:], separator)
ret, err = isZeroLengthPattern(pattern[patIdx:commaIdx]+pattern[closingIdx+1:], separator, validate)
if ret || err != nil {
return
}

patIdx = commaIdx + 1
}
return isZeroLengthPattern(pattern[patIdx:closingIdx]+pattern[closingIdx+1:], separator)
return isZeroLengthPattern(pattern[patIdx:closingIdx]+pattern[closingIdx+1:], separator, validate)
}

// no luck - validate the rest of the pattern
if !doValidatePattern(pattern, separator) {
if validate && !doValidatePattern(pattern, separator) {
return false, ErrBadPattern
}
return false, nil
Expand Down

0 comments on commit 3b1e3d1

Please sign in to comment.