af_zz_imgproxy: redirect to cached_url if cache already exists so that urls are a bit shorter (2)

master
Andrew Dolgov 5 years ago
parent e7edaca4db
commit c6ae5fbda1

@ -124,22 +124,22 @@ class Af_Zz_ImgProxy extends Plugin {
if (($scheme != 'https' && $scheme != "") || $is_remote) { if (($scheme != 'https' && $scheme != "") || $is_remote) {
if (strpos($url, "data:") !== 0) { if (strpos($url, "data:") !== 0) {
$parts = parse_url($url); /* we don't need to handle URLs where local cache already exists, tt-rss rewrites those automatically */
if (!$this->cache->exists(sha1($url))) {
foreach (explode(" " , $this->ssl_known_whitelist) as $host) { $parts = parse_url($url);
if (substr(strtolower($parts['host']), -strlen($host)) === strtolower($host)) {
$parts['scheme'] = 'https'; foreach (explode(" " , $this->ssl_known_whitelist) as $host) {
$url = build_url($parts); if (substr(strtolower($parts['host']), -strlen($host)) === strtolower($host)) {
if ($all_remote && $is_remote) { $parts['scheme'] = 'https';
break; $url = build_url($parts);
} else { if ($all_remote && $is_remote) {
return $url; break;
} else {
return $url;
}
} }
} }
}
/* we don't need to handle URLs where local cache already exists, tt-rss rewrites those automatically */
if (!$this->cache->exists(sha1($url))) {
return get_self_url_prefix() . "/public.php?op=pluginhandler&plugin=af_zz_imgproxy&pmethod=imgproxy&url=" . return get_self_url_prefix() . "/public.php?op=pluginhandler&plugin=af_zz_imgproxy&pmethod=imgproxy&url=" .
urlencode($url); urlencode($url);
} }

Loading…
Cancel
Save