diff --git a/data.go b/data.go index f1bcd6a..d590c6c 100644 --- a/data.go +++ b/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, "" } }