From 58f00893c70903fbd52cac11f4b5cb2ca441d779 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 10 Dec 2019 15:56:02 +0100 Subject: [PATCH] Use strings.TrimPrefix to simplify code --- gold.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gold.go b/gold.go index c17bf6c..b398034 100644 --- a/gold.go +++ b/gold.go @@ -6,6 +6,7 @@ import ( "io" "log" "net/url" + "strings" "github.com/microcosm-cc/bluemonday" bf "gopkg.in/russross/blackfriday.v2" @@ -163,9 +164,7 @@ func resolveRelativeURL(baseURL string, rel string) string { if u.IsAbs() { return rel } - if len(u.Path) > 0 && u.Path[0] == '/' { - u.Path = u.Path[1:] - } + u.Path = strings.TrimPrefix(u.Path, "/") base, err := url.Parse(baseURL) if err != nil {