From 53b30e267c26aba4890c5bfafd97ce2ac6482571 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Wed, 1 May 2013 12:16:17 +0200 Subject: [PATCH] Fix entry partial matching rules. --- src/http/Service.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 95d9edae8..9cb52b9c9 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -167,7 +167,7 @@ bool Service::removeFirstDomain(QString & hostname) return !hostname.isEmpty(); } -QList Service::searchEntries(const QString &text) +QList Service::searchEntries(const QString& text) { QList entries; @@ -175,19 +175,19 @@ QList Service::searchEntries(const QString &text) //Search entries matching the hostname QString hostname = QUrl(text).host(); - if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) - if (Database * db = dbWidget->database()) - if (Group * rootGroup = db->rootGroup()) + if (DatabaseWidget* dbWidget = m_dbTabWidget->currentDatabaseWidget()) + if (Database* db = dbWidget->database()) + if (Group* rootGroup = db->rootGroup()) do { - Q_FOREACH (Entry * entry, rootGroup->search(hostname, Qt::CaseInsensitive)) { + Q_FOREACH (Entry* entry, rootGroup->search(hostname, Qt::CaseInsensitive)) { QString title = entry->title(); QString url = entry->url(); //Filter to match hostname in Title and Url fields - if ( hostname.contains(title) - || hostname.contains(url) - || (matchUrlScheme(title) && hostname.contains(QUrl(title).host())) - || (matchUrlScheme(url) && hostname.contains(QUrl(url).host())) ) + if ( (!title.isEmpty() && hostname.contains(title)) + || (!url.isEmpty() && hostname.contains(url)) + || (matchUrlScheme(title) && hostname.endsWith(QUrl(title).host())) + || (matchUrlScheme(url) && hostname.endsWith(QUrl(url).host())) ) entries.append(entry); } } while(entries.isEmpty() && removeFirstDomain(hostname));