words: fix parser to handle missing newline at end

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2021-08-13 19:37:18 -07:00
parent c992504375
commit 954867fef5
1 changed files with 2 additions and 0 deletions

View File

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