From e846bc1d7d9424d14dea1621b89c10e57f5bb42a Mon Sep 17 00:00:00 2001 From: Feuerfuchs Date: Mon, 18 May 2020 20:35:31 +0200 Subject: Fix nav for both Gopher and Gemini --- internal/port/gemini.go | 11 ++++------- internal/port/gopher.go | 9 +++------ 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'internal/port') diff --git a/internal/port/gemini.go b/internal/port/gemini.go index 2695214..f574816 100644 --- a/internal/port/gemini.go +++ b/internal/port/gemini.go @@ -49,21 +49,18 @@ func urlToGeminiNav(url string) (items []GeminiNavItem) { parts = parts[:len(parts)-1] } - for i, part := range parts { + for _, part := range parts { partialURL = partialURL + "/" + part - current := false - if i == len(parts)-1 { - current = true - } - items = append(items, GeminiNavItem{ Label: part, URL: partialURL, - Current: current, + Current: false, }) } + items[len(items)-1].Current = true + return } diff --git a/internal/port/gopher.go b/internal/port/gopher.go index cb5e60c..fc7b754 100644 --- a/internal/port/gopher.go +++ b/internal/port/gopher.go @@ -69,18 +69,15 @@ func urlToGopherNav(url string) (items []GopherNavItem) { partialURL = partialURL + "/" + part } - current := false - if i == len(parts)-1 || (len(parts) == 2 && i == 0) { - current = true - } - items = append(items, GopherNavItem{ Label: part, URL: partialURL, - Current: current, + Current: false, }) } + items[len(items)-1].Current = true + return } -- cgit v1.2.3-70-g09d2