From 398cf0b312fa99428ffd9f634ccf2f61dac6bce4 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 24 Mar 2017 07:17:38 +0100 Subject: [PATCH] Small improvements in the search [skip ci] --- app/Support/Search/Search.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/Support/Search/Search.php b/app/Support/Search/Search.php index cc6bd5e9f3..21f6f8bf23 100644 --- a/app/Support/Search/Search.php +++ b/app/Support/Search/Search.php @@ -9,7 +9,7 @@ * See the LICENSE file for details. */ -declare(strict_types = 1); +declare(strict_types=1); namespace FireflyIII\Support\Search; @@ -37,6 +37,8 @@ class Search implements SearchInterface private $limit = 100; /** @var Collection */ private $modifiers; + /** @var string */ + private $originalQuery = ''; /** @var User */ private $user; /** @var array */ @@ -58,7 +60,10 @@ class Search implements SearchInterface */ public function getWordsAsString(): string { - return join(' ', $this->words); + $string = join(' ', $this->words); + if (strlen($string) === 0) { + return $this->originalQuery; + } } /** @@ -74,9 +79,10 @@ class Search implements SearchInterface */ public function parseQuery(string $query) { - $filteredQuery = $query; - $pattern = '/[a-z_]*:[0-9a-z-.]*/i'; - $matches = []; + $filteredQuery = $query; + $this->originalQuery = $query; + $pattern = '/[a-z_]*:[0-9a-z-.]*/i'; + $matches = []; preg_match_all($pattern, $query, $matches); foreach ($matches[0] as $match) {