forked from leftypol/leftypol
SearchService.php: fix matchStrings not matching flags
This commit is contained in:
parent
67d9a638db
commit
783f4d0a78
1 changed files with 2 additions and 2 deletions
|
|
@ -138,7 +138,7 @@ class SearchService {
|
||||||
private static function matchStrings(array $strings, array $fragments): array {
|
private static function matchStrings(array $strings, array $fragments): array {
|
||||||
return \array_filter($strings, function ($str) use ($fragments) {
|
return \array_filter($strings, function ($str) use ($fragments) {
|
||||||
// Saves the last position. We use this to ensure the fragments are one after the other.
|
// Saves the last position. We use this to ensure the fragments are one after the other.
|
||||||
$last_ret = 0;
|
$last_ret = -1;
|
||||||
foreach ($fragments as $fragment) {
|
foreach ($fragments as $fragment) {
|
||||||
if ($last_ret + 1 > \strlen($fragment)) {
|
if ($last_ret + 1 > \strlen($fragment)) {
|
||||||
// Cannot possibly match.
|
// Cannot possibly match.
|
||||||
|
|
@ -147,7 +147,7 @@ class SearchService {
|
||||||
|
|
||||||
$last_ret = \stripos($str, $fragment, $last_ret + 1);
|
$last_ret = \stripos($str, $fragment, $last_ret + 1);
|
||||||
if ($last_ret === false) {
|
if ($last_ret === false) {
|
||||||
// Exclude flags that don't much even a single fragment.
|
// Exclude flags that don't match even a single fragment.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue