From fc6c883eca97f8cc3f2231b06656c8763dbfdeb7 Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Tue, 17 Nov 2020 17:43:30 +0100 Subject: [PATCH] Fix paths --- posts.go | 6 +++--- utils.go | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/posts.go b/posts.go index 259d960..9f56969 100644 --- a/posts.go +++ b/posts.go @@ -252,9 +252,9 @@ func serveIndex(ic *indexConfig) func(w http.ResponseWriter, r *http.Request) { "Posts": posts, "HasPrev": hasPrev, "HasNext": hasNext, - "First": appConfig.Server.PublicAddress + path, - "Prev": appConfig.Server.PublicAddress + prevPath, - "Next": appConfig.Server.PublicAddress + nextPath, + "First": slashIfEmpty(path), + "Prev": slashIfEmpty(prevPath), + "Next": slashIfEmpty(nextPath), "SummaryTemplate": summaryTemplate, }, }) diff --git a/utils.go b/utils.go index 4848e13..c323844 100644 --- a/utils.go +++ b/utils.go @@ -100,3 +100,10 @@ func resolveURLReferences(base string, refs ...string) ([]string, error) { } return urls, nil } + +func slashIfEmpty(s string) string { + if s == "" { + return "/" + } + return s +}