Skip to content

Commit

Permalink
[4.x] Allow slashes in comb search queries (#9754)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell authored Mar 19, 2024
1 parent 84d5c23 commit 0964035
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Search/Comb/Comb.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public function setSettings($settings)
*/
private function preformat($raw_query)
{
return trim(mb_ereg_replace("[^\w\d\-\.:+\s@&’'‘]", '', $raw_query));
return trim(mb_ereg_replace("[^\w\d\-\.:+\s\\\/@&’'‘]", '', $raw_query));
}

/**
Expand Down
26 changes: 26 additions & 0 deletions tests/Search/CombTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,32 @@ public function it_can_search_for_plus_signs()
$this->assertSame(1, $result['info']['total_results']);
}

/**
* @test
**/
public function it_can_search_for_slashes()
{
$comb = new Comb([
['content' => 'Cont\ent'],
['content' => 'Cont/ent'],
]);

$result = $comb->lookUp('\\');
$this->assertIsArray($result);
$this->assertCount(2, $result);
$this->assertSame(1, $result['info']['total_results']);

$result = $comb->lookUp('/');
$this->assertIsArray($result);
$this->assertCount(2, $result);
$this->assertSame(1, $result['info']['total_results']);

$result = $comb->lookUp('Cont\\e');
$this->assertIsArray($result);
$this->assertCount(2, $result);
$this->assertSame(1, $result['info']['total_results']);
}

public static function searchesProvider()
{
return [
Expand Down

0 comments on commit 0964035

Please sign in to comment.