Resolve infuse routing issues
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ func (r *HTTPClient) Do(req *http.Request) (*http.Response, error) {
|
||||
}
|
||||
r.replaceHostIfNeeded(req)
|
||||
// check if Range header is set
|
||||
hasRangeHeader := req.Header.Get("Range") != ""
|
||||
hasRangeHeader := req.Header.Get("Range") != "" && req.Header.Get("Range") != "bytes=0-"
|
||||
|
||||
var resp *http.Response
|
||||
var err error
|
||||
|
||||
@@ -87,10 +87,16 @@ type TorrentInfo struct {
|
||||
}
|
||||
|
||||
func (i *TorrentInfo) IsDone() bool {
|
||||
selectedCount := 0
|
||||
for _, file := range i.Files {
|
||||
if file.Selected == 1 {
|
||||
selectedCount++
|
||||
}
|
||||
}
|
||||
if i.Progress != 100 {
|
||||
return false
|
||||
}
|
||||
return len(i.Files) == len(i.Links) && len(i.Files) > 0
|
||||
return selectedCount == len(i.Links) && len(i.Links) > 0
|
||||
}
|
||||
|
||||
func (i *TorrentInfo) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user