mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-12 13:32:40 +02:00
Fix code review feedback from internal UpContent code review
This commit is contained in:
parent
9b678fda97
commit
d1a3938b09
1 changed files with 3 additions and 6 deletions
9
data.go
9
data.go
|
|
@ -340,15 +340,12 @@ func NewRequest(r *http.Request, baseURL *url.URL) (*Request, error) {
|
|||
var additionalQuery string
|
||||
req := &Request{Original: r}
|
||||
|
||||
path := r.URL.EscapedPath()[1:] // the image url is stored in the path, so get image url from path but strip leading slash so it's not like /https://example.com
|
||||
|
||||
path := r.URL.EscapedPath()[1:] // strip leading slash
|
||||
decodedPath, err, additionalQuery := decodeURL(path) // Conditionally decode url path param if it is url encoded this enables us to process image urls with query params built in
|
||||
if err == nil {
|
||||
path = decodedPath
|
||||
}
|
||||
|
||||
req.URL, err = parseURL(path)
|
||||
|
||||
if err != nil || !req.URL.IsAbs() {
|
||||
// first segment should be options
|
||||
parts := strings.SplitN(path, "/", 2)
|
||||
|
|
@ -405,7 +402,7 @@ func decodeURL(s string) (string, error, string) {
|
|||
}
|
||||
|
||||
var isUrlEncoded = reIsEncodedUrl.MatchString(u)
|
||||
print(u, ": ", isUrlEncoded, "\n")
|
||||
|
||||
if isUrlEncoded {
|
||||
u, err := url.QueryUnescape(u)
|
||||
if err != nil {
|
||||
|
|
@ -419,7 +416,7 @@ func decodeURL(s string) (string, error, string) {
|
|||
|
||||
return prefix + u, err2, parsed.RawQuery
|
||||
} else {
|
||||
return prefix + u, nil, ""
|
||||
return s, nil, ""
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue