mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
Compare commits
2 Commits
v2024.3.3
...
bug/PS-117
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a8663f1f0 | ||
|
|
b35bb7a7a6 |
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Abstractions;
|
||||
@@ -85,6 +87,10 @@ namespace Bit.Core.Services
|
||||
{
|
||||
matchedCiphers.Add(c);
|
||||
}
|
||||
else if (RemoveDiacritics(c.Name)?.ToLower().Contains(query) ?? false)
|
||||
{
|
||||
lowPriorityMatchedCiphers.Add(c);
|
||||
}
|
||||
else if (query.Length >= 8 && c.Id.StartsWith(query))
|
||||
{
|
||||
lowPriorityMatchedCiphers.Add(c);
|
||||
@@ -93,6 +99,10 @@ namespace Bit.Core.Services
|
||||
{
|
||||
lowPriorityMatchedCiphers.Add(c);
|
||||
}
|
||||
else if (RemoveDiacritics(c.SubTitle)?.ToLower().Contains(query) ?? false)
|
||||
{
|
||||
lowPriorityMatchedCiphers.Add(c);
|
||||
}
|
||||
else if (c.Login?.Uri?.ToLower()?.Contains(query) ?? false)
|
||||
{
|
||||
lowPriorityMatchedCiphers.Add(c);
|
||||
@@ -165,5 +175,27 @@ namespace Bit.Core.Services
|
||||
matchedSends.AddRange(lowPriorityMatchSends);
|
||||
return matchedSends;
|
||||
}
|
||||
|
||||
private string RemoveDiacritics(string text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string formD = text.Normalize(NormalizationForm.FormD);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
foreach (char ch in formD)
|
||||
{
|
||||
UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(ch);
|
||||
if (uc != UnicodeCategory.NonSpacingMark)
|
||||
{
|
||||
sb.Append(ch);
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString().Normalize(NormalizationForm.FormC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user