From 1dda796e7c6043922180909bc0d87f97e6ecf7f0 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Tue, 5 Nov 2019 18:44:47 -0500 Subject: [PATCH] fix: resolves #492 Fixes an issue whereby hidden files (like `.DS_Store`) may be wrongly loaded as cheatsheets. --- internal/sheets/load.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/sheets/load.go b/internal/sheets/load.go index a90c1d0..5cadddb 100644 --- a/internal/sheets/load.go +++ b/internal/sheets/load.go @@ -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 }