From ce6c5364068413fdfb40eca55fb4445e1cd49ff1 Mon Sep 17 00:00:00 2001 From: tjp Date: Sun, 14 Jul 2024 13:26:32 -0600 Subject: default '1' gopher type when path == '/' --- actions.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'actions.go') diff --git a/actions.go b/actions.go index e521318..f497248 100644 --- a/actions.go +++ b/actions.go @@ -122,12 +122,22 @@ func purgeOldHistory(state *BrowserState) { } func gopherURL(u *url.URL) (string, sliderule.Status) { - if u.Scheme != "gopher" || len(u.Path) < 2 || !strings.HasPrefix(u.Path, "/") { + if u.Scheme != "gopher" || !strings.HasPrefix(u.Path, "/") { return u.String(), 0 } - itemType := u.Path[1] + + var itemType byte + var path string + if u.Path == "/" { + itemType = '1' + path = u.Path + } else { + itemType = u.Path[1] + path = u.Path[2:] + } + clone := *u - clone.Path = u.Path[2:] + clone.Path = path return clone.String(), sliderule.Status(itemType) } -- cgit v1.2.3