From e22c171b2989cd209e44f5bb275e94cdc58231bd Mon Sep 17 00:00:00 2001 From: Seednode Date: Tue, 7 Nov 2023 20:11:19 -0600 Subject: [PATCH] Terrible workaround for not URL-encoding path separators --- cmd/root.go | 2 +- cmd/sort.go | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index b5fc8b0..42377b1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,7 @@ import ( ) const ( - ReleaseVersion string = "3.2.3" + ReleaseVersion string = "3.2.4" ) var ( diff --git a/cmd/sort.go b/cmd/sort.go index 44bc441..b8ef453 100644 --- a/cmd/sort.go +++ b/cmd/sort.go @@ -91,6 +91,14 @@ Loop: return first, last, nil } +func pathUrlEscape(path string) string { + placeholder := strings.Replace(path, "/", "", -1) + + escaped := url.QueryEscape(placeholder) + + return strings.Replace(escaped, "", "/", -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(``, Prefix, mediaPrefix, - url.QueryEscape(first), + pathUrlEscape(first), queryParams, firstStatus)) html.WriteString(fmt.Sprintf(``, Prefix, mediaPrefix, - url.QueryEscape(prevPage), + pathUrlEscape(prevPage), queryParams, prevStatus)) html.WriteString(fmt.Sprintf(``, Prefix, mediaPrefix, - url.QueryEscape(nextPage), + pathUrlEscape(nextPage), queryParams, nextStatus)) html.WriteString(fmt.Sprintf(``, Prefix, mediaPrefix, - url.QueryEscape(last), + pathUrlEscape(last), queryParams, lastStatus))