fix searchterm parsing (#5501)

This commit is contained in:
Kevin Papst
2025-05-27 13:20:27 +02:00
committed by GitHub
parent b38c6fbb0e
commit f42d42f512
2 changed files with 3 additions and 1 deletions

View File

@@ -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];

View File

@@ -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],
];
}