diff options
| author | adnano <[email protected]> | 2020-09-29 21:27:16 -0400 |
|---|---|---|
| committer | adnano <[email protected]> | 2020-09-29 21:27:16 -0400 |
| commit | a8b63b59826c6c4bdce672d6f4723aebfae4347a (patch) | |
| tree | ecdd7b374e26b58468978f3247448d310bab280a /text.go | |
| parent | Create the certificate store if it does not exist (diff) | |
| download | go-gemini-a8b63b59826c6c4bdce672d6f4723aebfae4347a.tar.xz go-gemini-a8b63b59826c6c4bdce672d6f4723aebfae4347a.zip | |
Fix parsing of links without names
Diffstat (limited to 'text.go')
| -rw-r--r-- | text.go | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -78,10 +78,15 @@ func Parse(r io.Reader) Text { line = line[2:] line = strings.TrimLeft(line, spacetab) split := strings.IndexAny(line, spacetab) - url := line[:split] - name := line[split:] - name = strings.TrimLeft(name, spacetab) - t = append(t, LineLink{url, name}) + if split == -1 { + // line is a URL + t = append(t, LineLink{URL: line}) + } else { + url := line[:split] + name := line[split:] + name = strings.TrimLeft(name, spacetab) + t = append(t, LineLink{url, name}) + } } else if strings.HasPrefix(line, "*") { line = line[1:] line = strings.TrimLeft(line, spacetab) |