summaryrefslogtreecommitdiff
path: root/gopher/gophermap
diff options
context:
space:
mode:
authortjp <tjp@ctrl-c.club>2024-01-03 20:15:11 -0700
committertjp <tjp@ctrl-c.club>2024-01-03 20:15:11 -0700
commit69c5336ea11aa51e2b47526f7d6108ac42ddcef1 (patch)
tree7df4abb988ab9f1436985c4933f5edb539de7156 /gopher/gophermap
parent07309c877c40316ba2538f232770e8d987672ffb (diff)
optional tabs for gopher i lines
Diffstat (limited to 'gopher/gophermap')
-rw-r--r--gopher/gophermap/parse.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/gopher/gophermap/parse.go b/gopher/gophermap/parse.go
index 04286bd..e99fec6 100644
--- a/gopher/gophermap/parse.go
+++ b/gopher/gophermap/parse.go
@@ -32,15 +32,22 @@ func Parse(input io.Reader) (gopher.MapDocument, error) {
item := gopher.MapItem{Type: sr.Status(line[0])}
spl := bytes.Split(line[1:len(line)-2], []byte{'\t'})
- if len(spl) != 4 {
+ if item.Type != gopher.InfoMessageType && len(spl) != 4 {
return nil, InvalidLine(num)
}
item.Display = string(spl[0])
- item.Selector = string(spl[1])
- item.Hostname = string(spl[2])
- item.Port = string(spl[3])
- if _, err = strconv.Atoi(item.Port); err != nil {
- return nil, InvalidLine(num)
+
+ if len(spl) > 1 {
+ item.Selector = string(spl[1])
+ }
+ if len(spl) > 2 {
+ item.Hostname = string(spl[2])
+ }
+ if len(spl) > 3 {
+ item.Port = string(spl[3])
+ if _, err = strconv.Atoi(item.Port); err != nil {
+ return nil, InvalidLine(num)
+ }
}
doc = append(doc, item)