Fix URL not unescaped on archival process

This commit is contained in:
Radhi Fadlillah 2019-08-08 14:21:25 +07:00
parent 54e02e5c76
commit 0324784c7c

View file

@ -47,14 +47,13 @@ func ToResourceURL(uri string, base *nurl.URL) ResourceURL {
// So, for archival URL, we need to unescape the query and path first.
tmp, err := nurl.Parse(downloadURL)
if err == nil {
tmp.RawPath = tmp.Path
newQuery, _ := nurl.QueryUnescape(tmp.RawQuery)
if newQuery != "" {
tmp.RawQuery = newQuery
unescapedQuery, _ := nurl.QueryUnescape(tmp.RawQuery)
if unescapedQuery != "" {
tmp.RawQuery = unescapedQuery
}
archivalURL = tmp.String()
archivalURL = strings.Replace(archivalURL, tmp.EscapedPath(), tmp.Path, 1)
}
archivalURL = strings.ReplaceAll(archivalURL, "://", "/")