Merge pull request #384 from spytheman/master

Allow easy routing of URLs containing Cyrillic letters.
pull/393/head
Mike Cao 6 years ago committed by GitHub
commit c57ee8cb8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -78,8 +78,9 @@ class Router {
* @return Route|bool Matching route or false if no match * @return Route|bool Matching route or false if no match
*/ */
public function route(Request $request) { public function route(Request $request) {
$url_decoded = urldecode( $request->url );
while ($route = $this->current()) { while ($route = $this->current()) {
if ($route !== false && $route->matchMethod($request->method) && $route->matchUrl($request->url, $this->case_sensitive)) { if ($route !== false && $route->matchMethod($request->method) && $route->matchUrl($url_decoded, $this->case_sensitive)) {
return $route; return $route;
} }
$this->next(); $this->next();

@ -263,4 +263,16 @@ class RouterTest extends PHPUnit_Framework_TestCase
$this->check('404'); $this->check('404');
} }
// Passing URL parameters matched with regular expression for a URL containing Cyrillic letters:
function testRegExParametersCyrillic(){
$this->router->map('/категория/@name:[абвгдеёжзийклмнопрстуфхцчшщъыьэюя]+', function($name){
echo $name;
});
$this->request->url = urlencode('/категория/цветя');
$this->check('цветя');
}
} }

Loading…
Cancel
Save