Skip to content

Commit

Permalink
fix: remove extra ';' at the end of query if only 1 search query was …
Browse files Browse the repository at this point in the history
…submitted

(cherry picked from commit d707ea6)
  • Loading branch information
Mohammad-Alavi committed Sep 23, 2021
1 parent 604aabd commit 81f49eb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Traits/HasRequestCriteriaTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,17 @@ private function getSearchSegmentKeyValues($segment): array
private function arrayToSearchQuery(array $decodedSearchArray): string
{
$decodedSearchQuery = '';
foreach ($decodedSearchArray as $key => $value) {
$decodedSearchQuery .= "$key:$value;";

$fields = array_keys($decodedSearchArray);
$length = count($fields);
for ($i = 0; $i < $length; $i++) {
$field = $fields[$i];
$decodedSearchQuery .= "$field:$decodedSearchArray[$field]";
if ($length !== 1 && $i < $length - 1) {
$decodedSearchQuery .= ';';
}
}

return $decodedSearchQuery;
}

Expand Down

0 comments on commit 81f49eb

Please sign in to comment.