mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
Compare commits
4 Commits
community/
...
community/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7500073e7e | ||
|
|
6b77fee72b | ||
|
|
a0e62771fd | ||
|
|
733464e05d |
@@ -5,6 +5,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Models.View;
|
using Bit.Core.Models.View;
|
||||||
|
using Bit.Core.Utilities;
|
||||||
|
|
||||||
namespace Bit.Core.Services
|
namespace Bit.Core.Services
|
||||||
{
|
{
|
||||||
@@ -76,12 +77,12 @@ namespace Bit.Core.Services
|
|||||||
ct.ThrowIfCancellationRequested();
|
ct.ThrowIfCancellationRequested();
|
||||||
var matchedCiphers = new List<CipherView>();
|
var matchedCiphers = new List<CipherView>();
|
||||||
var lowPriorityMatchedCiphers = new List<CipherView>();
|
var lowPriorityMatchedCiphers = new List<CipherView>();
|
||||||
query = query.Trim().ToLower();
|
query = query.Trim().ToLower().RemoveDiacritics();
|
||||||
|
|
||||||
foreach (var c in ciphers)
|
foreach (var c in ciphers)
|
||||||
{
|
{
|
||||||
ct.ThrowIfCancellationRequested();
|
ct.ThrowIfCancellationRequested();
|
||||||
if (c.Name?.ToLower().Contains(query) ?? false)
|
if (c.Name?.ToLower().RemoveDiacritics().Contains(query) ?? false)
|
||||||
{
|
{
|
||||||
matchedCiphers.Add(c);
|
matchedCiphers.Add(c);
|
||||||
}
|
}
|
||||||
@@ -89,7 +90,7 @@ namespace Bit.Core.Services
|
|||||||
{
|
{
|
||||||
lowPriorityMatchedCiphers.Add(c);
|
lowPriorityMatchedCiphers.Add(c);
|
||||||
}
|
}
|
||||||
else if (c.SubTitle?.ToLower().Contains(query) ?? false)
|
else if (c.SubTitle?.ToLower().RemoveDiacritics().Contains(query) ?? false)
|
||||||
{
|
{
|
||||||
lowPriorityMatchedCiphers.Add(c);
|
lowPriorityMatchedCiphers.Add(c);
|
||||||
}
|
}
|
||||||
|
|||||||
34
src/Core/Utilities/StringExtensions.cs
Normal file
34
src/Core/Utilities/StringExtensions.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Bit.Core.Utilities
|
||||||
|
{
|
||||||
|
public static class StringExtensions
|
||||||
|
{
|
||||||
|
public static string RemoveDiacritics(this string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
{
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
var normalizedString = text.Normalize(NormalizationForm.FormD);
|
||||||
|
var stringBuilder = new StringBuilder(capacity: normalizedString.Length);
|
||||||
|
|
||||||
|
for (int i = 0; i < normalizedString.Length; i++)
|
||||||
|
{
|
||||||
|
char c = normalizedString[i];
|
||||||
|
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
|
||||||
|
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
|
||||||
|
{
|
||||||
|
stringBuilder.Append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringBuilder
|
||||||
|
.ToString()
|
||||||
|
.Normalize(NormalizationForm.FormC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user