Terrible workaround for not URL-encoding path separators

This commit is contained in:
Seednode 2023-11-07 20:11:19 -06:00
parent 9953bb50dc
commit e22c171b29
2 changed files with 13 additions and 5 deletions

View File

@ -12,7 +12,7 @@ import (
)
const (
ReleaseVersion string = "3.2.3"
ReleaseVersion string = "3.2.4"
)
var (

View File

@ -91,6 +91,14 @@ Loop:
return first, last, nil
}
func pathUrlEscape(path string) string {
placeholder := strings.Replace(path, "/", "<path_placeholder>", -1)
escaped := url.QueryEscape(placeholder)
return strings.Replace(escaped, "<path_placeholder>", "/", -1)
}
func paginateSorted(path, first, last, queryParams string, regexes *regexes, formats types.Types) (string, error) {
split, err := split(path, regexes)
if err != nil {
@ -148,28 +156,28 @@ func paginateSorted(path, first, last, queryParams string, regexes *regexes, for
html.WriteString(fmt.Sprintf(`<button onclick="window.location.href = '%s%s%s%s';"%s>First</button>`,
Prefix,
mediaPrefix,
url.QueryEscape(first),
pathUrlEscape(first),
queryParams,
firstStatus))
html.WriteString(fmt.Sprintf(`<button onclick="window.location.href = '%s%s%s%s';"%s>Prev</button>`,
Prefix,
mediaPrefix,
url.QueryEscape(prevPage),
pathUrlEscape(prevPage),
queryParams,
prevStatus))
html.WriteString(fmt.Sprintf(`<button onclick="window.location.href = '%s%s%s%s';"%s>Next</button>`,
Prefix,
mediaPrefix,
url.QueryEscape(nextPage),
pathUrlEscape(nextPage),
queryParams,
nextStatus))
html.WriteString(fmt.Sprintf(`<button onclick="window.location.href = '%s%s%s%s';"%s>Last</button>`,
Prefix,
mediaPrefix,
url.QueryEscape(last),
pathUrlEscape(last),
queryParams,
lastStatus))