opt: resource file detection optimize

This commit is contained in:
Xiao YiFang 2022-08-24 21:30:26 +08:00
parent 5180dfb35e
commit 2adfdc031b

View file

@ -95,7 +95,19 @@ inline bool isExternalLink(QUrl const &url) {
inline bool isHtmlResources(QUrl const &url) { inline bool isHtmlResources(QUrl const &url) {
auto fileName = url.fileName(); auto fileName = url.fileName();
auto ext=fileName.mid(fileName.lastIndexOf(".")); auto ext=fileName.mid(fileName.lastIndexOf("."));
QStringList extensions{".css",".woff",".woff2","ttf",".bmp" ,".jpg", ".png",".gif", ".tif",".wav", ".ogg", ".oga", ".mp3", ".mp4", ".aac", ".flac",".mid", ".wv",".ape"} ; QStringList extensions{ ".css", ".woff", ".woff2", ".ttf", ".otf", ".bmp", ".jpg", ".png", ".gif", ".tif",
".wav", ".ogg", ".oga", ".mp3", ".mp4", ".aac", ".flac", ".mid", ".wv", ".ape" };
//some url has the form like https://xxxx/audio?file=***.mp3&a=1 etc links.
if( ext.isEmpty() )
{
for( QString extension : extensions )
{
if( url.url().contains( extension ) )
return true;
}
return false;
}
return extensions.contains( ext, Qt::CaseInsensitive ); return extensions.contains( ext, Qt::CaseInsensitive );
} }