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

This commit is contained in:
Andrew Dolgov 2019-08-14 10:01:05 +03:00
parent e7edaca4db
commit c6ae5fbda1
1 changed files with 14 additions and 14 deletions

View File

@ -124,22 +124,22 @@ class Af_Zz_ImgProxy extends Plugin {
if (($scheme != 'https' && $scheme != "") || $is_remote) {
if (strpos($url, "data:") !== 0) {
$parts = parse_url($url);
foreach (explode(" " , $this->ssl_known_whitelist) as $host) {
if (substr(strtolower($parts['host']), -strlen($host)) === strtolower($host)) {
$parts['scheme'] = 'https';
$url = build_url($parts);
if ($all_remote && $is_remote) {
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))) {
$parts = parse_url($url);
foreach (explode(" " , $this->ssl_known_whitelist) as $host) {
if (substr(strtolower($parts['host']), -strlen($host)) === strtolower($host)) {
$parts['scheme'] = 'https';
$url = build_url($parts);
if ($all_remote && $is_remote) {
break;
} else {
return $url;
}
}
}
return get_self_url_prefix() . "/public.php?op=pluginhandler&plugin=af_zz_imgproxy&pmethod=imgproxy&url=" .
urlencode($url);
}