Skip to content

Commit

Permalink
feat: optimize HasFilepathPrefix
Browse files Browse the repository at this point in the history
  • Loading branch information
orisano committed Jun 4, 2019
1 parent 8abb0c4 commit ab04b8a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,10 @@ func excludeFile(path, buildcontext string) bool {

// HasFilepathPrefix checks if the given file path begins with prefix
func HasFilepathPrefix(path, prefix string, prefixMatchOnly bool) bool {
path = filepath.Clean(path)
prefix = filepath.Clean(prefix)
pathArray := strings.Split(path, "/")
prefixArray := strings.Split(prefix, "/")
path = filepath.Clean(path)
pathArray := strings.SplitN(path, "/", len(prefixArray)+1)

if len(pathArray) < len(prefixArray) {
return false
Expand Down

0 comments on commit ab04b8a

Please sign in to comment.