words: fix parser to handle missing newline at end
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user