From 686e85e1aaae9a28e8a016303e641b43612dfe03 Mon Sep 17 00:00:00 2001 From: ShiKhu Date: Wed, 4 Aug 2021 23:54:17 +0800 Subject: [PATCH] fix (backend-assets): use QueryEscape for the CachePath (so it includes all the parts along with port) --- backend/pkg/url/assets/url.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/backend/pkg/url/assets/url.go b/backend/pkg/url/assets/url.go index 66402ab28..ea7d45ac7 100644 --- a/backend/pkg/url/assets/url.go +++ b/backend/pkg/url/assets/url.go @@ -4,6 +4,7 @@ import ( "net/url" "path/filepath" "strconv" + "strings" ) func getSessionKey(sessionID uint64) string { @@ -56,15 +57,16 @@ func GetFullCachableURL(baseURL string, relativeURL string) (string, bool) { const OPENREPLAY_QUERY_START = "OPENREPLAY_QUERY" func getCachePath(rawurl string) string { - u, _ := url.Parse(rawurl) - s := "/" + u.Scheme + "/" + u.Hostname() + u.Path - if u.RawQuery != "" { - if (s[len(s) - 1] != '/') { - s += "/" - } - s += OPENREPLAY_QUERY_START + url.PathEscape(u.RawQuery) - } - return s + return strings.ReplaceAll(url.QueryEscape(rawurl), "%", "!") // s3 keys are ok with "!" + // u, _ := url.Parse(rawurl) + // s := "/" + u.Scheme + "/" + u.Hostname() + u.Path + // if u.RawQuery != "" { + // if (s[len(s) - 1] != '/') { + // s += "/" + // } + // s += OPENREPLAY_QUERY_START + url.PathEscape(u.RawQuery) + // } + // return s } func getCachePathWithKey(sessionID uint64, rawurl string) string {