sync: better trim authors lines

This commit is contained in:
nemunaire 2018-12-09 19:34:01 +01:00
parent f3eabd74fc
commit 8c87451d80

View File

@ -6,6 +6,7 @@ import (
"path"
"regexp"
"strings"
"unicode"
"srs.epita.fr/fic-server/libfic"
"github.com/julienschmidt/httprouter"
@ -36,7 +37,8 @@ func getAuthors(i Importer, tname string) ([]string, error) {
} else {
var ret []string
re := regexp.MustCompile("^([^<]+)(?: +<(.*)>)?$")
for _, a := range strings.Split(strings.TrimSpace(authors), "\n") {
for _, a := range strings.Split(authors, "\n") {
a = strings.TrimFunc(a, unicode.IsSpace)
grp := re.FindStringSubmatch(a)
if len(grp) < 2 || grp[2] == "" {
ret = append(ret, a)