mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08:00
Don't use hardcoded URL scheme list
This is to avoid the list being outdated.
This commit is contained in:
parent
d3936c07c7
commit
0279b80b46
@ -38,6 +38,7 @@
|
||||
#include <QStringList>
|
||||
#include <QStringView>
|
||||
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "ui_downloadfromurldialog.h"
|
||||
#include "utils.h"
|
||||
|
||||
@ -47,16 +48,13 @@ namespace
|
||||
{
|
||||
bool isDownloadable(const QString &str)
|
||||
{
|
||||
return (str.startsWith(u"http://", Qt::CaseInsensitive)
|
||||
|| str.startsWith(u"https://", Qt::CaseInsensitive)
|
||||
|| str.startsWith(u"ftp://", Qt::CaseInsensitive)
|
||||
return (Net::DownloadManager::hasSupportedScheme(str)
|
||||
|| str.startsWith(u"magnet:", Qt::CaseInsensitive)
|
||||
|| ((str.size() == 40) && !str.contains(QRegularExpression(u"[^0-9A-Fa-f]"_qs))) // v1 hex-encoded SHA-1 info-hash
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
|| ((str.size() == 64) && !str.contains(QRegularExpression(u"[^0-9A-Fa-f]"_qs))) // v2 hex-encoded SHA-256 info-hash
|
||||
#endif
|
||||
|| ((str.size() == 40) && !str.contains(QRegularExpression(u"[^0-9A-Fa-f]"_qs))) // v1 hex-encoded SHA-1 info-hash
|
||||
|| ((str.size() == 32) && !str.contains(QRegularExpression(u"[^2-7A-Za-z]"_qs)))); // v1 Base32 encoded SHA-1 info-hash
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user