mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07: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
1 changed files with 3 additions and 5 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue