mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-08 17:45:10 -04:00
Allow abbreviation of search field names
This allows `t:word` instead of `title:word` and `p:word` instead of `password:word`, and so on. The rule is that an abbreviated name expands to the first field name that starts with it, with exceptions `u:` expanding to `username:` instead of `url:` and `pw:` expanding to `password:`.
This commit is contained in:
parent
0a3b19edf2
commit
41131ae48d
3 changed files with 43 additions and 25 deletions
|
@ -96,7 +96,7 @@ void TestEntrySearcher::testSearch()
|
|||
e3->setGroup(group3);
|
||||
|
||||
Entry* e3b = new Entry();
|
||||
e3b->setTitle("test search test");
|
||||
e3b->setTitle("test search test 123");
|
||||
e3b->setUsername("test@email.com");
|
||||
e3b->setPassword("realpass");
|
||||
e3b->setGroup(group3);
|
||||
|
@ -108,16 +108,31 @@ void TestEntrySearcher::testSearch()
|
|||
m_searchResult = m_entrySearcher.search("search term", m_rootGroup);
|
||||
QCOMPARE(m_searchResult.count(), 3);
|
||||
|
||||
m_searchResult = m_entrySearcher.search("123", m_rootGroup);
|
||||
QCOMPARE(m_searchResult.count(), 2);
|
||||
|
||||
m_searchResult = m_entrySearcher.search("search term", group211);
|
||||
QCOMPARE(m_searchResult.count(), 1);
|
||||
|
||||
// Test advanced search terms
|
||||
m_searchResult = m_entrySearcher.search("title:123", m_rootGroup);
|
||||
QCOMPARE(m_searchResult.count(), 1);
|
||||
|
||||
m_searchResult = m_entrySearcher.search("t:123", m_rootGroup);
|
||||
QCOMPARE(m_searchResult.count(), 1);
|
||||
|
||||
m_searchResult = m_entrySearcher.search("password:testpass", m_rootGroup);
|
||||
QCOMPARE(m_searchResult.count(), 1);
|
||||
|
||||
m_searchResult = m_entrySearcher.search("pw:testpass", m_rootGroup);
|
||||
QCOMPARE(m_searchResult.count(), 1);
|
||||
|
||||
m_searchResult = m_entrySearcher.search("!user:email.com", m_rootGroup);
|
||||
QCOMPARE(m_searchResult.count(), 5);
|
||||
|
||||
m_searchResult = m_entrySearcher.search("!u:email.com", m_rootGroup);
|
||||
QCOMPARE(m_searchResult.count(), 5);
|
||||
|
||||
m_searchResult = m_entrySearcher.search("*user:\".*@.*\\.com\"", m_rootGroup);
|
||||
QCOMPARE(m_searchResult.count(), 1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue