add '/' implicitly to console_subpath (#1371)

This commit is contained in:
Harshavardhana
2022-01-08 20:56:54 -08:00
committed by GitHub
parent eadc449bb0
commit ef1dc172fd
3 changed files with 10 additions and 9 deletions

View File

@@ -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