words: fix parser to handle missing newline at end

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/2655/head
Brad Fitzpatrick 3 years ago
parent c992504375
commit 954867fef5

@ -48,6 +48,8 @@ func parseWords(txt []byte) []string {
i := bytes.IndexByte(txt, '\n') i := bytes.IndexByte(txt, '\n')
if i != -1 { if i != -1 {
word, txt = word[:i], txt[i+1:] word, txt = word[:i], txt[i+1:]
} else {
txt = nil
} }
if word := strings.TrimSpace(string(word)); word != "" && word[0] != '#' { if word := strings.TrimSpace(string(word)); word != "" && word[0] != '#' {
ret = append(ret, word) ret = append(ret, word)

Loading…
Cancel
Save