aboutsummaryrefslogtreecommitdiff
path: root/text.go
diff options
context:
space:
mode:
authoradnano <[email protected]>2020-09-29 21:27:16 -0400
committeradnano <[email protected]>2020-09-29 21:27:16 -0400
commita8b63b59826c6c4bdce672d6f4723aebfae4347a (patch)
treeecdd7b374e26b58468978f3247448d310bab280a /text.go
parentCreate the certificate store if it does not exist (diff)
downloadgo-gemini-a8b63b59826c6c4bdce672d6f4723aebfae4347a.tar.xz
go-gemini-a8b63b59826c6c4bdce672d6f4723aebfae4347a.zip
Fix parsing of links without names
Diffstat (limited to 'text.go')
-rw-r--r--text.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/text.go b/text.go
index 3811169..5130e8a 100644
--- a/text.go
+++ b/text.go
@@ -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)