Browse Source

Don't use hardcoded URL scheme list

This is to avoid the list being outdated.
adaptive-webui-19844
Chocobo1 2 years ago
parent
commit
0279b80b46
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 8
      src/gui/downloadfromurldialog.cpp

8
src/gui/downloadfromurldialog.cpp

@ -38,6 +38,7 @@ @@ -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 @@ -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…
Cancel
Save