Skip to content

Commit

Permalink
Add "parent directory match" priority between exact and host match
Browse files Browse the repository at this point in the history
  • Loading branch information
m5w6 authored and droidmonkey committed Sep 21, 2021
1 parent 34ed63f commit 9aec84d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/browser/BrowserService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,11 @@ int BrowserService::sortPriority(const QStringList& urls, const QString& siteUrl
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
if (url.host() == siteUrl.host()) {
return 80;
Expand Down
9 changes: 6 additions & 3 deletions tests/TestBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,13 @@ void TestBrowser::testSortPriority_data()

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) No Scheme") << "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 << 85;
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/"
<< "https://github.net/" << 60;
Expand Down

0 comments on commit 9aec84d

Please sign in to comment.