diff --git a/convids/methods.go b/convids/methods.go index 71689a9..c79c873 100644 --- a/convids/methods.go +++ b/convids/methods.go @@ -10,11 +10,15 @@ import ( ) var ErrNoName = errors.New("missing name") +var ErrNilPointer = errors.New("nil pointer") var animePattern = `^\[.+\] ` var animeRegexp = regexp.MustCompile(animePattern) func (s *Show) Match(path string) (bool, error) { + if s == nil { + return false, ErrNilPointer + } if s.Pattern != "" { return s.matchRegexp(path) } @@ -50,12 +54,15 @@ func (s *Show) matchRegexp(path string) (f bool, err error) { } func (ss *Shows) All() iter.Seq[*Show] { + if ss == nil { + return func(func(*Show) bool) {} + } return slices.Values(*ss) } func (d *Data) AllShows(silent bool) iter.Seq[*Show] { return func(yield func(*Show) bool) { - if d.Config == nil { + if d == nil || d.Config == nil { return } for _, show := range d.Config.Shows {