🐛 Protect from nil pointers
This commit is contained in:
parent
ec3db89d1a
commit
a9fe6f30fc
1 changed files with 8 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue