/** * Route does not match URI with conditions */ public function testRouteDoesNotMatchResourceWithConditions() { $resource = 'hello/Josh/and/John'; $route = new Route('/hello/:first/and/:second', function () { }); $route->conditions(array('first' => '[a-z]{3,}')); $result = $route->matches($resource); $this->assertFalse($result); $this->assertEquals($route->params(), array()); }
<?php /* |-------------------------------------------------------------------------- | Application Route Constraint Patterns |-------------------------------------------------------------------------- | | If you would like a route parameter to always be constrained by a | given regular expression, here is where you can register all filters | for an application. | */ Route::conditions(array('_id' => '[0-9a-fA-F]{24}', 'start' => '(19|20)\\d\\d[\\-\\/.](0[1-9]|1[012])[\\-\\/.](0[1-9]|[12][0-9]|3[01])', 'end' => '(19|20)\\d\\d[\\-\\/.](0[1-9]|1[012])[\\-\\/.](0[1-9]|[12][0-9]|3[01])', 'token' => '[a-zA-Z0-9_-]{64,128}', 'version' => '[0-9]{1,6}')); /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Slim the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::group('/v1', function () { App::response()->headers->set('X-OpenDRadio-Media-Type', 'opendradio.v1'); // Playlist Route::get('/playlist', 'App\\Http\\Controllers\\PlaylistController:getIndex')->name('playlist_url'); Route::group('/broadcasts', function () { // Get latest resources Route::get('/latest', 'App\\Http\\Controllers\\BroadcastController:getLatest')->name('broadcasts_latest_url'); // Get many resources by date range