Route with \w.* RegExp

I've setup two routes that should have the same behavior:


    $router->add(
        "/a{hash:\w.*}",
        array(
            "controller" => "index",
            "action"     => "content"
        )
    );

    $router->add(
        "/b(\w.*)",
        array(
            "controller" => "index",
            "action"     => "content",
            "params"     => 1
        )
    );

The in the controller I have the "contentAction" like this:

 public function contentAction($hash=''){
        $this->view->disable();
        echo "hash: $hash";

Now, when do the requests to the diferent urls I get distinct results:

Request: /aX123
Response: hash: X123

Request: /bX123
Response: hash: 123

Has you can see, in the second request the first char of the hash is truncated and the "X" is removed from the parameter. Should both routes produce the same results?



85.4k

The problem is using the parameter "params", this special parameter removes the first character (slash) since is intended to be in the form /(.*). Using a different name you would not have this problem.