diff options
-rw-r--r-- | gopher/gophermap/extended.go | 26 |
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: |