Skip to content

Commit

Permalink
Fixed case-insensitive search for page/media suggestions. Closes #282.
Browse files Browse the repository at this point in the history
  • Loading branch information
impworks committed Feb 4, 2024
1 parent c65f249 commit 5c2b9b9
Show file tree
Hide file tree
Showing 8 changed files with 1,072 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Bonsai/Areas/Admin/Logic/PagesManagerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ private IEnumerable<PageAlias> GetPageAliases(string aliases, string title, Page
Page = page,
Key = PageHelper.EncodeTitle(x).ToLowerInvariant(),
Title = x,
NormalizedTitle = PageHelper.NormalizeTitle(x),
Order = idx
}
);
Expand Down
8 changes: 4 additions & 4 deletions src/Bonsai/Areas/Admin/Logic/SuggestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public async Task<IReadOnlyList<PageTitleExtendedVM>> GetPickablePagesAsync(Pick

if (!string.IsNullOrEmpty(request.Query))
{
var queryLower = request.Query.ToLower();
q = q.Where(x => x.Aliases.Any(y => y.Title.ToLower().Contains(queryLower)));
var queryNormalized = PageHelper.NormalizeTitle(request.Query);
q = q.Where(x => x.Aliases.Any(y => y.NormalizedTitle.Contains(queryNormalized)));
}

if (request.Types?.Length > 0)
Expand Down Expand Up @@ -137,8 +137,8 @@ public async Task<IReadOnlyList<MediaThumbnailVM>> GetPickableMediaAsync(PickReq

if (!string.IsNullOrEmpty(request.Query))
{
var queryLower = request.Query.ToLower();
q = q.Where(x => x.Title.ToLower().Contains(queryLower));
var queryNormalized = PageHelper.NormalizeTitle(request.Query);
q = q.Where(x => x.NormalizedTitle.Contains(queryNormalized));
}

if (request.Types?.Length > 0)
Expand Down
Loading

0 comments on commit 5c2b9b9

Please sign in to comment.