fix: resolves #492

Fixes an issue whereby hidden files (like `.DS_Store`) may be wrongly
loaded as cheatsheets.
This commit is contained in:
Chris Lane 2019-11-05 18:44:47 -05:00
parent 5301442f7c
commit 1dda796e7c
1 changed files with 7 additions and 2 deletions

View File

@ -48,8 +48,13 @@ func Load(cheatpaths []cp.Cheatpath) ([]map[string]sheet.Sheet, error) {
"/",
)
// ignore dotfiles. Otherwise, we'll likely load .git/*
if strings.HasPrefix(title, ".") {
// ignore hidden files and directories. Otherwise, we'll likely load
// .git/* and .DS_Store.
//
// NB: this is still somewhat brittle in that it will miss files
// contained within hidden directories in the middle of a path, though
// that should not realistically occur.
if strings.HasPrefix(title, ".") || strings.HasPrefix(info.Name(), "."){
return nil
}