Skip to content

Commit

Permalink
Merge branch 'release/2.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Christensen committed May 23, 2016
2 parents b5ee850 + 5849aba commit d719511
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,28 @@ class Lexer extends BaseLexer
{
// Overriding this to include $ search by.
const REGEX_VALUE = '/(\w|\$|\-|\+|\*|\?|\:|\.|\%[0-9a-f]{2})+/Ai';

/**
* Custom replace - to %2D for easier find by.
*
* @param string $code request uri params
* @return \Xiag\Rql\Parser\TokenStream
*/
public function tokenize($code)
{
// Replace for each string value between (), there can be many rql params.
if (strpos($code, 'string:') !== false) {
preg_match_all('/\(.*?string:(.*?)\)/', $code, $matches);
if (array_key_exists(1, $matches) && !empty($matches)) {
foreach ($matches[1] as $match) {
if (strpos($match, '-') !== false) {
$new = preg_replace('/-/', '%2D', 'string:' . $match, 1);
$code = preg_replace('/string:' . $match . '/', $new, $code, 1);
}
}
}
}

return parent::tokenize($code);
}
}

0 comments on commit d719511

Please sign in to comment.