mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 16:57:53 +00:00
Custom regex fix
- Fixed issue with custom-regex maching both host-name and url (issue: #503). - Changed TestRouter so host-name is always set.
This commit is contained in:
@@ -60,7 +60,7 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((bool)preg_match($this->regex, $request->getHost() . $url) !== false);
|
return ((bool)preg_match($this->regex, $url) !== false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -171,4 +171,16 @@ class RouterUrlTest extends \PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCustomRegex()
|
||||||
|
{
|
||||||
|
TestRouter::request()->setHost('google.com');
|
||||||
|
|
||||||
|
TestRouter::get('/admin/', function() {
|
||||||
|
return 'match';
|
||||||
|
})->setMatch('/^\/admin\/?(.*)/i');
|
||||||
|
|
||||||
|
$output = TestRouter::debugOutput('/admin/asd/bec/123', 'get');
|
||||||
|
$this->assertEquals('match', $output);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,11 @@
|
|||||||
class TestRouter extends \Pecee\SimpleRouter\SimpleRouter
|
class TestRouter extends \Pecee\SimpleRouter\SimpleRouter
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
static::request()->setHost('testhost.com');
|
||||||
|
}
|
||||||
|
|
||||||
public static function debugNoReset($testUrl, $testMethod = 'get')
|
public static function debugNoReset($testUrl, $testMethod = 'get')
|
||||||
{
|
{
|
||||||
$request = static::request();
|
$request = static::request();
|
||||||
|
|||||||
Reference in New Issue
Block a user