mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-12 21:42:40 +02:00
Modifications of image proxy
This commit is contained in:
parent
7eeacfca7a
commit
2913b086ac
1 changed files with 12 additions and 0 deletions
12
data.go
12
data.go
|
|
@ -336,6 +336,7 @@ func NewRequest(r *http.Request, baseURL *url.URL) (*Request, error) {
|
|||
req := &Request{Original: r}
|
||||
|
||||
path := r.URL.EscapedPath()[1:] // strip leading slash
|
||||
path, err = decodeUrl(path)
|
||||
req.URL, err = parseURL(path)
|
||||
if err != nil || !req.URL.IsAbs() {
|
||||
// first segment should be options
|
||||
|
|
@ -378,3 +379,14 @@ func parseURL(s string) (*url.URL, error) {
|
|||
s = reCleanedURL.ReplaceAllString(s, "$1://$2")
|
||||
return url.Parse(s)
|
||||
}
|
||||
|
||||
var reIsEncodedUrl = regexp.MustCompile(`^https?%`)
|
||||
|
||||
func decodeUrl(s string) (string, error) {
|
||||
var isUrlEncoded = reIsEncodedUrl.MatchString(s)
|
||||
if isUrlEncoded {
|
||||
return url.QueryUnescape(s)
|
||||
} else {
|
||||
return s, nil
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue