Skip to content

parts with multiple parameters #5

Description

@mindplay-dk

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions