From cca640958dc2724165c1297c36ecde0c2925ee95 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sat, 27 Jun 2026 07:56:51 +1000 Subject: [PATCH] fix: strip base URL path prefix from helm chart download URLs When a helm repo's base URL includes a path (e.g. stakater.github.io/ stakater-charts), the merger extracted the full path from download URLs causing duplication: /stakater-charts/stakater-charts/reloader.tgz. Now strips the base URL's path prefix from same-host download URLs so the proxy constructs the correct upstream URL. --- internal/virtual/helm_merger.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/virtual/helm_merger.go b/internal/virtual/helm_merger.go index db1d206..94641d7 100644 --- a/internal/virtual/helm_merger.go +++ b/internal/virtual/helm_merger.go @@ -65,11 +65,12 @@ func (m *HelmMerger) MergeIndexes(members []MemberIndex, proxyBaseURL string) ([ if baseHost != "" && extractHost(u) != baseHost { continue } + relPath := extractPathRelativeToBase(u, member.BaseURL) ver.URLs[i] = fmt.Sprintf("%s/api/v1/%s/%s/%s", strings.TrimRight(proxyBaseURL, "/"), routePrefix, member.RemoteName, - extractPath(u)) + relPath) } else { ver.URLs[i] = fmt.Sprintf("%s/api/v1/%s/%s/%s", strings.TrimRight(proxyBaseURL, "/"), @@ -102,6 +103,18 @@ func extractHost(rawURL string) string { return rest[:slashIdx] } +func extractPathRelativeToBase(rawURL, baseURL string) string { + fullPath := extractPath(rawURL) + basePath := extractPath(baseURL) + if basePath != "" { + basePath = strings.TrimRight(basePath, "/") + "/" + if strings.HasPrefix(fullPath, basePath) { + return fullPath[len(basePath):] + } + } + return fullPath +} + func extractPath(rawURL string) string { idx := strings.Index(rawURL, "://") if idx == -1 {