From f42d42f512317ec648e47b9a71cb41f6700d7c38 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Tue, 27 May 2025 13:20:27 +0200 Subject: [PATCH] fix searchterm parsing (#5501) --- src/Utils/SearchTermPart.php | 2 +- tests/Utils/SearchTermPartTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Utils/SearchTermPart.php b/src/Utils/SearchTermPart.php index d5b4558d..e9f71599 100644 --- a/src/Utils/SearchTermPart.php +++ b/src/Utils/SearchTermPart.php @@ -18,7 +18,7 @@ final class SearchTermPart public function __construct(string $term) { if (str_contains($term, ':')) { - $tmp = explode(':', $term); + $tmp = explode(':', $term, 2); // search strings like 'name:' are NOT field searches, but simply terms with a colon if (\count($tmp) === 2 && $tmp[1] !== '') { $this->field = $tmp[0]; diff --git a/tests/Utils/SearchTermPartTest.php b/tests/Utils/SearchTermPartTest.php index 156e2a68..7ed1383f 100644 --- a/tests/Utils/SearchTermPartTest.php +++ b/tests/Utils/SearchTermPartTest.php @@ -27,6 +27,8 @@ class SearchTermPartTest extends TestCase ['bar', 'bar', null, false], ['hello:world', 'world', 'hello', false], ['hello:!world', 'world', 'hello', true], + ['url:https://www.example.com', 'https://www.example.com', 'url', false], + ['url:!https://www.example.com:8080/test.html', 'https://www.example.com:8080/test.html', 'url', true], ]; }