mirror of https://github.com/KDE/kasts.git
Improve check for existing podcasts
The feedExists method will now also take query parameters into account. BUG: 461877
This commit is contained in:
parent
7e92b5c280
commit
d192784e12
|
@ -584,13 +584,10 @@ void DataManager::loadEntry(const QString id) const
|
|||
|
||||
bool DataManager::feedExists(const QString &url)
|
||||
{
|
||||
// Try to account for some common cases where the URL is different but is
|
||||
// actually pointing to the same data. Currently covering:
|
||||
// - http vs https
|
||||
// - encoded vs non-encoded URLs
|
||||
QString cleanUrl = QUrl(url).authority() + QUrl(url).path(QUrl::FullyDecoded);
|
||||
// using cleanUrl to do "fuzzy" check on the podcast URL
|
||||
QString cleanedUrl = cleanUrl(url);
|
||||
for (QString listUrl : m_feedmap) {
|
||||
if (cleanUrl == (QUrl(listUrl).authority() + QUrl(listUrl).path(QUrl::FullyDecoded))) {
|
||||
if (cleanedUrl == cleanUrl(listUrl)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -722,3 +719,14 @@ QStringList DataManager::getIdsFromModelIndexList(const QModelIndexList &list) c
|
|||
qCDebug(kastsDataManager) << "Ids of selection:" << ids;
|
||||
return ids;
|
||||
}
|
||||
|
||||
QString DataManager::cleanUrl(const QString &url)
|
||||
{
|
||||
// this is a method to create a "canonical" version of a podcast url which
|
||||
// would account for some common cases where the URL is different but is
|
||||
// actually pointing to the same data. Currently covering:
|
||||
// - http vs https (scheme is actually removed altogether!)
|
||||
// - encoded vs non-encoded URLs
|
||||
return QUrl(url).authority() + QUrl(url).path(QUrl::FullyDecoded)
|
||||
+ (QUrl(url).hasQuery() ? QStringLiteral("?") + QUrl(url).query(QUrl::FullyDecoded) : QStringLiteral(""));
|
||||
}
|
||||
|
|
|
@ -102,6 +102,8 @@ private:
|
|||
void loadEntry(QString id) const;
|
||||
void updateQueueListnrs() const;
|
||||
|
||||
QString cleanUrl(const QString &url);
|
||||
|
||||
QStringList getIdsFromModelIndexList(const QModelIndexList &list) const;
|
||||
|
||||
mutable QHash<QString, Feed *> m_feeds; // hash of pointers to all feeds in db, key = url (lazy loading)
|
||||
|
|
Loading…
Reference in New Issue