index out of range bugfix

This commit is contained in:
ston1th 2016-11-17 00:01:18 +01:00
commit f4fcf0d9a8

View file

@ -14,7 +14,7 @@ import (
const timeFmt = "2006-01-02 15:04:05"
var titleRe = regexp.MustCompile("[^a-zA-Z0-9+]+")
var titleRe = regexp.MustCompile("[^a-zA-Z0-9+ ]+")
func now() string {
return time.Now().Format(timeFmt)
@ -225,8 +225,6 @@ func (e *Engine) GetAll(public bool) (t Titles, err error) {
return
}
}
t = make(Titles, len(res.Hits)-1)
i := 0
for _, v := range res.Hits {
if v.ID == "Index" {
continue
@ -241,8 +239,7 @@ func (e *Engine) GetAll(public bool) (t Titles, err error) {
}
f, ok := field.(*document.TextField)
if ok {
t[i] = Title{string(f.Value()), v.ID}
i++
t = append(t, Title{string(f.Value()), v.ID})
break
}
}