sync: better trim authors lines
This commit is contained in:
parent
f3eabd74fc
commit
8c87451d80
@ -6,6 +6,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
"srs.epita.fr/fic-server/libfic"
|
"srs.epita.fr/fic-server/libfic"
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
@ -36,7 +37,8 @@ func getAuthors(i Importer, tname string) ([]string, error) {
|
|||||||
} else {
|
} else {
|
||||||
var ret []string
|
var ret []string
|
||||||
re := regexp.MustCompile("^([^<]+)(?: +<(.*)>)?$")
|
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)
|
grp := re.FindStringSubmatch(a)
|
||||||
if len(grp) < 2 || grp[2] == "" {
|
if len(grp) < 2 || grp[2] == "" {
|
||||||
ret = append(ret, a)
|
ret = append(ret, a)
|
||||||
|
Loading…
Reference in New Issue
Block a user