1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-07 11:03:54 +00:00

[PS-1352] Fix ignore diacritics in search (#2044)

* Fix ignore diacritics in search

This change updates the search function to ignore diacritical marks in search results. Marks are stripped from both the search input and results.

* Removed logs, added null or whitespace validation and improved formatting

Co-authored-by: aj-rosado <109146700+aj-rosado@users.noreply.github.com>
Co-authored-by: Andre Rosado <arosado@bitwarden.com>
This commit is contained in:
noncenz
2023-01-05 11:34:06 -05:00
committed by GitHub
parent acc587ce45
commit 0e856d2add
2 changed files with 38 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ using System.Threading;
using System.Threading.Tasks;
using Bit.Core.Abstractions;
using Bit.Core.Models.View;
using Bit.Core.Utilities;
namespace Bit.Core.Services
{
@@ -76,12 +77,12 @@ namespace Bit.Core.Services
ct.ThrowIfCancellationRequested();
var matchedCiphers = new List<CipherView>();
var lowPriorityMatchedCiphers = new List<CipherView>();
query = query.Trim().ToLower();
query = query.Trim().ToLower().RemoveDiacritics();
foreach (var c in ciphers)
{
ct.ThrowIfCancellationRequested();
if (c.Name?.ToLower().Contains(query) ?? false)
if (c.Name?.ToLower().RemoveDiacritics().Contains(query) ?? false)
{
matchedCiphers.Add(c);
}
@@ -89,7 +90,7 @@ namespace Bit.Core.Services
{
lowPriorityMatchedCiphers.Add(c);
}
else if (c.SubTitle?.ToLower().Contains(query) ?? false)
else if (c.SubTitle?.ToLower().RemoveDiacritics().Contains(query) ?? false)
{
lowPriorityMatchedCiphers.Add(c);
}