Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit ab04b8a

Browse files
committed
feat: optimize HasFilepathPrefix
1 parent 8abb0c4 commit ab04b8a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

pkg/util/fs_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,10 @@ func excludeFile(path, buildcontext string) bool {
563563

564564
// HasFilepathPrefix checks if the given file path begins with prefix
565565
func HasFilepathPrefix(path, prefix string, prefixMatchOnly bool) bool {
566-
path = filepath.Clean(path)
567566
prefix = filepath.Clean(prefix)
568-
pathArray := strings.Split(path, "/")
569567
prefixArray := strings.Split(prefix, "/")
568+
path = filepath.Clean(path)
569+
pathArray := strings.SplitN(path, "/", len(prefixArray)+1)
570570

571571
if len(pathArray) < len(prefixArray) {
572572
return false

0 commit comments

Comments
 (0)