Resolve infuse routing issues

This commit is contained in:
Ben Sarmiento
2024-01-20 14:51:16 +01:00
parent 14f6169601
commit a6b02ba74e
5 changed files with 57 additions and 38 deletions

View File

@@ -9,15 +9,17 @@ func customPathEscape(input string) string {
// First, URL-escape the path segments
segments := strings.Split(input, "/")
for i, segment := range segments {
segments[i] = url.PathEscape(segment)
escapedSegment := strings.ReplaceAll(segment, "%", "ZURG25")
escapedSegment = url.PathEscape(escapedSegment)
escapedSegment = strings.ReplaceAll(escapedSegment, "ZURG25", "%25")
segments[i] = escapedSegment
}
escapedPath := strings.Join(segments, "/")
// Convert any XML-escaped sequences back to URL-escaped sequences
escapedPath = strings.Replace(escapedPath, "&", "%26", -1) // for &
escapedPath = strings.Replace(escapedPath, "<", "%3C", -1) // for <
escapedPath = strings.Replace(escapedPath, ">", "%3E", -1) // for >
escapedPath = strings.Replace(escapedPath, "\"", "%22", -1) // for "
escapedPath = strings.Replace(escapedPath, "'", "%27", -1) // for '
escapedPath = strings.Replace(escapedPath, ":", "%3A", -1) // for :
escapedPath = strings.ReplaceAll(escapedPath, "$", "%24")
escapedPath = strings.ReplaceAll(escapedPath, "&", "%26")
escapedPath = strings.ReplaceAll(escapedPath, "+", "%2B")
escapedPath = strings.ReplaceAll(escapedPath, ":", "%3A")
escapedPath = strings.ReplaceAll(escapedPath, "@", "%40")
return escapedPath
}