Add "parent directory match" priority between exact and host match

This commit is contained in:
m5w6 2021-09-04 23:41:37 +02:00 committed by Jonathan White
parent 34ed63f495
commit 9aec84dee7
2 changed files with 11 additions and 3 deletions

View File

@ -948,6 +948,11 @@ int BrowserService::sortPriority(const QStringList& urls, const QString& siteUrl
return 90; return 90;
} }
// Parent directory match
if (url.isParentOf(siteUrl) || url.isParentOf(formUrl)) {
return 85;
}
// Match without path (ie, FQDN match), form url prioritizes lower than site url // Match without path (ie, FQDN match), form url prioritizes lower than site url
if (url.host() == siteUrl.host()) { if (url.host() == siteUrl.host()) {
return 80; return 80;

View File

@ -165,10 +165,13 @@ void TestBrowser::testSortPriority_data()
QTest::newRow("Site Query Mismatch") << siteUrl << siteUrl + "?test=test" << formUrl << 90; QTest::newRow("Site Query Mismatch") << siteUrl << siteUrl + "?test=test" << formUrl << 90;
QTest::newRow("Path Mismatch (site)") << "https://github.com/" << siteUrl << formUrl << 80; QTest::newRow("Path Mismatch (site)") << "https://github.com/" << siteUrl << formUrl << 85;
QTest::newRow("Path Mismatch (site) No Scheme") << "github.com" << siteUrl << formUrl << 80; QTest::newRow("Path Mismatch (site) No Scheme") << "github.com" << siteUrl << formUrl << 85;
QTest::newRow("Path Mismatch (form)") << "https://github.com/" QTest::newRow("Path Mismatch (form)") << "https://github.com/"
<< "https://github.net" << formUrl << 70; << "https://github.net" << formUrl << 85;
QTest::newRow("Path Mismatch (diff parent)") << "https://github.com/keepassxreboot" << siteUrl << formUrl << 80;
QTest::newRow("Path Mismatch (diff parent, form)") << "https://github.com/keepassxreboot"
<< "https://github.net" << formUrl << 70;
QTest::newRow("Subdomain Mismatch (site)") << siteUrl << "https://sub.github.com/" QTest::newRow("Subdomain Mismatch (site)") << siteUrl << "https://sub.github.com/"
<< "https://github.net/" << 60; << "https://github.net/" << 60;