public function getUrl()
{
if (empty($this->url)) {
$url = $this->httpRequest()->getCurrentUrl(true)->getPath();
// we need to have the trailing slash because of the match inside matchRequest
// and also when matching the default method, we can do an incorrect match if we don't have the start and end slash
$this->url = $this->str($url)->trimRight('/')->val() . '/';
}
return $this->url;
}
public function testSetGetUrl() { $url = 'http://api.example.com/mock-api-class-router/'; $r = new Router('ExampleApi', 'Webiny\\Component\\Rest\\Tests\\Mocks\\MockApiClassRouter', true, self::$cache); $r->setUrl($url); $this->assertSame('/mock-api-class-router/', $r->getUrl()); }