Skip to content

Commit

Permalink
additional al(pha)num routing. no notation matches any character in a…
Browse files Browse the repository at this point in the history
… single segment.
  • Loading branch information
TomK committed Jan 28, 2015
1 parent aebf2d6 commit 3989e22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/Routing/Router.php
Expand Up @@ -162,18 +162,22 @@ public static function convertSimpleRoute($route)

if(strstr($route, '{'))
{
$repl["/{" . "$idPat\@alphanum}/"] = "(?P<$1>\w+)";
$repl["/{" . "$idPat\@alnum}/"] = "(?P<$1>\w+)";
$repl["/{" . "$idPat\@alpha}/"] = "(?P<$1>[a-zA-Z]+)";
$repl["/{" . "$idPat\@all}/"] = "(?P<$1>.+?)";
$repl["/{" . "$idPat\@num}/"] = "(?P<$1>\d+)";
$repl["/{" . "$idPat}/"] = "(?P<$1>\w+)";
$repl["/{" . "$idPat}/"] = "(?P<$1>.+)";
}

if(strstr($route, ':'))
{
$repl["/\:$idPat\@alphanum/"] = "(?P<$1>\w+)";
$repl["/\:$idPat\@alnum/"] = "(?P<$1>\w+)";
$repl["/\:$idPat\@alpha/"] = "(?P<$1>[a-zA-Z]+)";
$repl["/\:$idPat\@all/"] = "(?P<$1>.+?)";
$repl["/\:$idPat\@num/"] = "(?P<$1>\d+)";
$repl["/\:$idPat/"] = "(?P<$1>\w+)";
$repl["/\:$idPat/"] = "(?P<$1>.+)";
}

if(!empty($repl))
Expand Down
8 changes: 6 additions & 2 deletions tests/Cubex/Routing/RouterTest.php
Expand Up @@ -128,11 +128,15 @@ public function simpleRouteProvider()
['{var@alpha}', '(?P<var>[a-zA-Z]+)'],
['{var@all}', '(?P<var>.+?)'],
['{var@num}', '(?P<var>\d+)'],
['{var}', '(?P<var>\w+)'],
['{var@alphanum}', '(?P<var>\w+)'],
['{var@alnum}', '(?P<var>\w+)'],
['{var}', '(?P<var>.+)'],
[':var@alpha', '(?P<var>[a-zA-Z]+)'],
[':var@all', '(?P<var>.+?)'],
[':var@num', '(?P<var>\d+)'],
[':var', '(?P<var>\w+)'],
[':var@alphanum', '(?P<var>\w+)'],
[':var@alnum', '(?P<var>\w+)'],
[':var', '(?P<var>.+)'],
];
}

Expand Down

0 comments on commit 3989e22

Please sign in to comment.