summaryrefslogtreecommitdiff
path: root/gopher/gophermap/extended.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-10-31 17:31:30 -0600
committertjpcc <tjp@ctrl-c.club>2023-10-31 17:31:30 -0600
commit5be7e44150d31582e6d8577d48c842a421fa8ddc (patch)
tree18f63f9bf87611840683c30fab289d89e4b19354 /gopher/gophermap/extended.go
parent4c817bf712e4ffed34fdd78375fcd7157cd14dc3 (diff)
enable optional selector/host/port in extended gophermap lines
fixes #11
Diffstat (limited to 'gopher/gophermap/extended.go')
-rw-r--r--gopher/gophermap/extended.go26
1 files changed, 20 insertions, 6 deletions
diff --git a/gopher/gophermap/extended.go b/gopher/gophermap/extended.go
index 9692c51..8e48e99 100644
--- a/gopher/gophermap/extended.go
+++ b/gopher/gophermap/extended.go
@@ -108,16 +108,30 @@ outer:
item = gopher.MapItem{Type: types.Status(line[0])}
spl = strings.Split(line[1:], "\t")
- if len(spl) != 4 {
- return doc, InvalidLine(num)
- }
+
item.Display = string(spl[0])
- item.Selector = string(spl[1])
- item.Hostname = string(spl[2])
- item.Port = string(spl[3])
+
+ if len(spl) == 1 {
+ item.Selector = location.Path
+ } else {
+ item.Selector = string(spl[1])
+ }
+
+ if len(spl) < 3 {
+ item.Hostname = location.Hostname()
+ } else {
+ item.Hostname = string(spl[2])
+ }
+
+ if len(spl) < 4 {
+ item.Port = location.Port()
+ } else {
+ item.Port = string(spl[3])
+ }
if _, err = strconv.Atoi(item.Port); err != nil {
return doc, InvalidLine(num)
}
+
doc.Lines = append(doc.Lines, item)
next: