This commit is contained in:
kervala 2016-12-10 19:47:19 +01:00
commit f2368f2a91

View file

@ -4625,34 +4625,21 @@ namespace NLGUI
result = url; result = url;
string tmp; string tmp;
// folder used for images cache if (toLower(result).find("file:") == 0 && result.size() > 5)
static const string cacheDir = "cache";
string::size_type protocolPos = toLower(result).find("://");
if (protocolPos != string::npos)
{ {
// protocol present, it's an url so file must be searched in cache folder result = result.substr(5, result.size()-5);
// TODO: case of special characters & and ?
result = cacheDir + result.substr(protocolPos+2);
// if the file is already cached, use it
if (CFile::fileExists(result)) tmp = result;
} }
else else if (result.find("://") != string::npos || result.find("//") == 0)
{ {
// Url is a file ? // http://, https://, etc or protocol-less url "//domain.com/image.png"
if (toLower(result).find("file:") == 0) return false;
{ }
result = result.substr(5, result.size()-5);
}
tmp = CPath::lookup (CFile::getFilename(result), false, false, false); tmp = CPath::lookup (CFile::getFilename(result), false, false, false);
if (tmp.empty()) if (tmp.empty())
{ {
// try to find in local directory // try to find in local directory
tmp = CPath::lookup (result, false, false, true); tmp = CPath::lookup (result, false, false, true);
}
} }
if (!tmp.empty()) if (!tmp.empty())