Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard no longer works when route ends on slash #4

Closed
weierophinney opened this issue Dec 31, 2019 · 3 comments
Closed

Wildcard no longer works when route ends on slash #4

weierophinney opened this issue Dec 31, 2019 · 3 comments

Comments

@weierophinney
Copy link
Member

One can reproduce this using:

$request = new \Zend\Http\Request;
$request->setUri('http://www.test.nl/bla/');

$route = \Zend\Router\Http\Wildcard::factory([]);
$match = $route->match($request);

// Now `$match === null`

Was introduced in zendframework/zend-router#47 by @weierophinney


Originally posted by @roelvanduijnhoven at zendframework/zend-router#49

@weierophinney
Copy link
Member Author

Excuse me; I think this bug was not recently introduced. But matches existing behaviour.

As this will be deprecated; feel free to close.

I'll roll my own wildcard implementation for now that simply consumes the remainder of the path.


Originally posted by @roelvanduijnhoven at zendframework/zend-router#49 (comment)

@weierophinney
Copy link
Member Author

Reference for anybody looking for something like what I described:

class MatchEverything implements RouteInterface
{
    /** @var array */
    private $defaults;

    public function __construct(array $defaults)
    {
        $this->defaults = $defaults;
    }

    public function getAssembledParams()
    {
        return [];
    }

    public static function factory($options = [])
    {
        return new self($options['defaults'] ?? []);
    }

    public function match(Request $request, $pathOffset = null)
    {
        if (!method_exists($request, 'getUri')) {
            return null;
        }

        $remainder = substr($request->getUri()->getPath(), $pathOffset);

        return new RouteMatch($this->defaults, strlen($remainder));
    }

    public function assemble(array $params = [], array $options = [])
    {
        return '';
    }
}

Originally posted by @roelvanduijnhoven at zendframework/zend-router#49 (comment)

@samsonasik
Copy link
Member

I am closing it as wildcard is deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants