From 3cde12ce9beb0ff9cd73b37ea63a50a85e744da8 Mon Sep 17 00:00:00 2001 From: Dominik Braun Date: Fri, 4 Dec 2020 21:23:22 +0100 Subject: [PATCH] Add Entry.URLWithTrailingSlash method for normalizing repo URLs Signed-off-by: Dominik Braun --- pkg/repo/chartrepo.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 92892bb85..3305bdf77 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -292,3 +292,13 @@ func (e *Entry) String() string { } return string(buf) } + +// URLWithTrailingSlash returns the repository URL with a trailing slash. +// If the URL already ends with a slash, it will be returned unchanged. +func (e *Entry) URLWithTrailingSlash() string { + if e.URL[len(e.URL)-1:] == "/" { + return e.URL + } + + return e.URL + "/" +}