TreeRoute icon indicating copy to clipboard operation
TreeRoute copied to clipboard

parts with multiple parameters

Open mindplay-dk opened this issue 10 years ago • 1 comments

URL parts with multiple parameters is a common scenario, supported by every router I know of - for some reason, it doesn't work with this router.

I wrote the following failing test case:

        $this->specify('should match multiple regexp in params', function () use ($router) {
            $router->get('/archive/{year:^[0-9]+$}-{month:^[0-9]+$}-{day:^[0-9]+$}', 'archive');
            $result = $router->resolve('GET', '/archive/2015-31-01');
            $this->assertEquals('archive', $result['handler']);
            $this->assertEquals('2015', $result['params']['year']);
            $this->assertEquals('31', $result['params']['month']);
            $this->assertEquals('01', $result['params']['day']);
        });

Of course, you can work around this, by further parsing a matched parameter like for example {date:^[0-9]+\-[0-9]+\-[0-9]+$}, but it shouldn't be necessary. I think the assumption that every part is either a fixed string or a single parameter is too limited.

mindplay-dk avatar Jul 14 '15 15:07 mindplay-dk

Added support for that in my fork here

mindplay-dk avatar Jul 14 '15 17:07 mindplay-dk