Commit c1b6e879 authored by Christopher Brown's avatar Christopher Brown

minor addition to #8238

parent 396e7513
......@@ -894,14 +894,10 @@ func (a *App) ImageProxyAdder() func(string) string {
}
return func(url string) string {
if url == "" || strings.HasPrefix(url, siteURL) || strings.HasPrefix(url, proxyURL) {
if url == "" || url[0] == '/' || strings.HasPrefix(url, siteURL) || strings.HasPrefix(url, proxyURL) {
return url
}
if url[0] == '/' {
url = siteURL + url[1:]
}
switch proxyType {
case "atmos/camo":
mac := hmac.New(sha1.New, []byte(options))
......
......@@ -221,6 +221,12 @@ func TestImageProxy(t *testing.T) {
ImageURL: "http://mymattermost.com/myimage",
ProxiedImageURL: "http://mymattermost.com/myimage",
},
"willnorris/imageproxy_PathOnly": {
ProxyType: "willnorris/imageproxy",
ProxyURL: "https://127.0.0.1",
ImageURL: "/myimage",
ProxiedImageURL: "/myimage",
},
"willnorris/imageproxy_EmptyImageURL": {
ProxyType: "willnorris/imageproxy",
ProxyURL: "https://127.0.0.1",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment