Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Wildcard no longer works when route ends on slash #49

Open
roelvanduijnhoven opened this issue Jul 4, 2018 · 3 comments
Open

Wildcard no longer works when route ends on slash #49

roelvanduijnhoven opened this issue Jul 4, 2018 · 3 comments

Comments

@roelvanduijnhoven
Copy link

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 #47 by @weierophinney

@roelvanduijnhoven
Copy link
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.

@roelvanduijnhoven
Copy link
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 '';
    }
}

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-router; a new issue has been opened at laminas/laminas-router#4.

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

No branches or pull requests

2 participants