github.com/arneball/complete@v1.1.2/match/file.go (about) 1 package match 2 3 import "strings" 4 5 // File returns true if prefix can match the file 6 func File(file, prefix string) bool { 7 // special case for current directory completion 8 if file == "./" && (prefix == "." || prefix == "") { 9 return true 10 } 11 if prefix == "." && strings.HasPrefix(file, ".") { 12 return true 13 } 14 15 file = strings.TrimPrefix(file, "./") 16 prefix = strings.TrimPrefix(prefix, "./") 17 18 return strings.HasPrefix(file, prefix) 19 }