mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-12 21:42: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
|
var additionalQuery string
|
||||||
req := &Request{Original: r}
|
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
|
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 {
|
if err == nil {
|
||||||
path = decodedPath
|
path = decodedPath
|
||||||
}
|
}
|
||||||
|
|
||||||
req.URL, err = parseURL(path)
|
req.URL, err = parseURL(path)
|
||||||
|
|
||||||
if err != nil || !req.URL.IsAbs() {
|
if err != nil || !req.URL.IsAbs() {
|
||||||
// first segment should be options
|
// first segment should be options
|
||||||
parts := strings.SplitN(path, "/", 2)
|
parts := strings.SplitN(path, "/", 2)
|
||||||
|
|
@ -405,7 +402,7 @@ func decodeURL(s string) (string, error, string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var isUrlEncoded = reIsEncodedUrl.MatchString(u)
|
var isUrlEncoded = reIsEncodedUrl.MatchString(u)
|
||||||
print(u, ": ", isUrlEncoded, "\n")
|
|
||||||
if isUrlEncoded {
|
if isUrlEncoded {
|
||||||
u, err := url.QueryUnescape(u)
|
u, err := url.QueryUnescape(u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -419,7 +416,7 @@ func decodeURL(s string) (string, error, string) {
|
||||||
|
|
||||||
return prefix + u, err2, parsed.RawQuery
|
return prefix + u, err2, parsed.RawQuery
|
||||||
} else {
|
} else {
|
||||||
return prefix + u, nil, ""
|
return s, nil, ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue