Skip to content

Commit 6d692af

Browse files
committed
bug #735 Allow to search blog posts with unicode characters (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Allow to search blog posts with unicode characters This fixes #734. The search engine is now more strict because it's case sensitive (if the post title is `Lorém ipsum`, `lorém` and `Lorem` gives no results; you must search for `Lorém`). I'd say it's OK because we're not building a real search engine. Thoughts? Commits ------- 0e1c9d3 Allow to search blog posts with unicode characters
2 parents f4a7ac8 + 0e1c9d3 commit 6d692af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Repository/PostRepository.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ public function findBySearchQuery(string $rawQuery, int $limit = Post::NUM_ITEMS
9494
*/
9595
private function sanitizeSearchQuery(string $query): string
9696
{
97-
return preg_replace('/[^[:alnum:] ]/', '', trim(preg_replace('/[[:space:]]+/', ' ', $query)));
97+
return trim(preg_replace('/[[:space:]]+/', ' ', $query));
9898
}
9999

100100
/**
101101
* Splits the search query into terms and removes the ones which are irrelevant.
102102
*/
103103
private function extractSearchTerms(string $searchQuery): array
104104
{
105-
$terms = array_unique(explode(' ', mb_strtolower($searchQuery)));
105+
$terms = array_unique(explode(' ', $searchQuery));
106106

107107
return array_filter($terms, function ($term) {
108108
return 2 <= mb_strlen($term);

0 commit comments

Comments
 (0)