fix (backend-assets): use QueryEscape for the CachePath (so it includes all the parts along with port)

This commit is contained in:
ShiKhu 2021-08-04 23:54:17 +08:00
parent a98cbe883c
commit 686e85e1aa

View file

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