From ef1dc172fd46ce002463c58b2dff8111ed1c4d88 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 8 Jan 2022 20:56:54 -0800 Subject: [PATCH] add '/' implicitly to console_subpath (#1371) --- go.mod | 2 +- go.sum | 4 ++-- restapi/configure_console.go | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index fe86d72b7..e1361f530 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/minio/minio-go/v7 v7.0.20 github.com/minio/operator v0.0.0-20211011212245-31460bbbc4b7 github.com/minio/operator/logsearchapi v0.0.0-20211011212245-31460bbbc4b7 - github.com/minio/pkg v1.1.11 + github.com/minio/pkg v1.1.14 github.com/minio/selfupdate v0.4.0 github.com/mitchellh/go-homedir v1.1.0 github.com/rs/xid v1.3.0 diff --git a/go.sum b/go.sum index add1e06a7..e750e33b7 100644 --- a/go.sum +++ b/go.sum @@ -933,8 +933,8 @@ github.com/minio/pkg v1.0.3/go.mod h1:obU54TZ9QlMv0TRaDgQ/JTzf11ZSXxnSfLrm4tMtBP github.com/minio/pkg v1.0.4/go.mod h1:obU54TZ9QlMv0TRaDgQ/JTzf11ZSXxnSfLrm4tMtBP8= github.com/minio/pkg v1.0.11/go.mod h1:32x/3OmGB0EOi1N+3ggnp+B5VFkSBBB9svPMVfpnf14= github.com/minio/pkg v1.1.3/go.mod h1:32x/3OmGB0EOi1N+3ggnp+B5VFkSBBB9svPMVfpnf14= -github.com/minio/pkg v1.1.11 h1:FQMYrOZzZenQUVwvxM0YjoAZB15Wb+m3TZSu33Lynx0= -github.com/minio/pkg v1.1.11/go.mod h1:2WJAxesjzmPK9MnLZKm5n1hVYfBg04f2GQs6N5ImNU8= +github.com/minio/pkg v1.1.14 h1:9tGPH6p0YEsIOHOY3sh2Yl5Dn0JNTkNOdZW/p+MKIi4= +github.com/minio/pkg v1.1.14/go.mod h1:2WJAxesjzmPK9MnLZKm5n1hVYfBg04f2GQs6N5ImNU8= github.com/minio/selfupdate v0.3.1/go.mod h1:b8ThJzzH7u2MkF6PcIra7KaXO9Khf6alWPvMSyTDCFM= github.com/minio/selfupdate v0.4.0 h1:A7t07pN4Ch1tBTIRStW0KhUVyykz+2muCqFsITQeEW8= github.com/minio/selfupdate v0.4.0/go.mod h1:mcDkzMgq8PRcpCRJo/NlPY7U45O5dfYl2Y0Rg7IustY= diff --git a/restapi/configure_console.go b/restapi/configure_console.go index 2d6caa79f..bdcc26215 100644 --- a/restapi/configure_console.go +++ b/restapi/configure_console.go @@ -27,7 +27,6 @@ import ( "log" "net" "net/http" - "os" "path/filepath" "strings" "sync" @@ -36,6 +35,7 @@ import ( "github.com/klauspost/compress/gzhttp" portal_ui "github.com/minio/console/portal-ui" + "github.com/minio/pkg/env" "github.com/minio/pkg/mimedb" "github.com/go-openapi/errors" @@ -352,12 +352,13 @@ func configureServer(s *http.Server, _, _ string) { func getSubPath() string { subPathOnce.Do(func() { - if v := os.Getenv("CONSOLE_SUBPATH"); v != "" { - // make sure the subpath has a trailing slash - if !strings.HasSuffix(v, "/") { - v = fmt.Sprintf("%s/", v) + if v := env.Get("CONSOLE_SUBPATH", ""); v != "" { + // Replace all unnecessary `\` to `/` + // also add pro-actively at the end. + subPath = filepath.Clean(filepath.ToSlash(v)) + SlashSeparator + if !strings.HasPrefix(subPath, SlashSeparator) { + subPath = SlashSeparator + subPath } - subPath = v } }) return subPath