feat: optimize HasFilepathPrefix

This commit is contained in:
Nao YONASHIRO 2019-06-04 18:10:23 +09:00
parent c87d2dba9c
commit 02d1ce5e1b
1 changed files with 2 additions and 2 deletions

View File

@ -576,10 +576,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