Skip to content

Commit

Permalink
Fixed tags array cap, so that it can never be < 1, which would trigge…
Browse files Browse the repository at this point in the history
…r panic if there aren't any tags to display
  • Loading branch information
aQaTL committed Nov 1, 2018
1 parent 98fc000 commit 9cbc751
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions nyaa_cui.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (

"regexp"

"sort"

"github.com/aqatl/mal/dialog"
ns "github.com/aqatl/mal/nyaa_scraper"
"github.com/fatih/color"
"github.com/jroimartin/gocui"
"github.com/urfave/cli"
"sort"
)

func malNyaaCui(ctx *cli.Context) error {
Expand Down Expand Up @@ -127,7 +128,7 @@ type nyaaCui struct {
MaxPages int
LoadedPages int

TitleFilter *regexp.Regexp
TitleFilter *regexp.Regexp
QualityFilter *regexp.Regexp

ResultsView *gocui.View
Expand Down Expand Up @@ -394,7 +395,7 @@ func (nc *nyaaCui) ChangeFilter() {
var tagRegex = `(?U)\[(.+)\]`

func (nc *nyaaCui) FilterByTag() {
tags := make([]string, 1, len(nc.Results))
tags := make([]string, 1, len(nc.Results)+1)
tagsDup := make(map[string]struct{})
re := regexp.MustCompile(tagRegex)
for _, result := range nc.Results {
Expand Down Expand Up @@ -454,7 +455,7 @@ func (nc *nyaaCui) FilterByTag() {
var qualityTagRegex = `(\d{3,4}p)`

func (nc *nyaaCui) FilterByQuality() {
tags := make([]string, 1, len(nc.Results))
tags := make([]string, 1, len(nc.Results)+1)
tagsDup := make(map[string]struct{})
re := regexp.MustCompile(qualityTagRegex)
for _, result := range nc.Results {
Expand Down

0 comments on commit 9cbc751

Please sign in to comment.