File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -400,7 +400,23 @@ public function requestTargettingApi($request = null)
400400 return true ;
401401 }
402402
403- return $ this ->getApiRouteCollectionFromRequest ($ request ) instanceof ApiRouteCollection;
403+ if ($ collection = $ this ->getApiRouteCollectionFromRequest ($ request ))
404+ {
405+ try
406+ {
407+ $ collection ->match ($ request );
408+
409+ return true ;
410+ }
411+ catch (NotFoundHttpException $ exception )
412+ {
413+ // If we don't find a matching route then we'll let this
414+ // fall through so that false is returned as the
415+ // request is not targetting the API.
416+ }
417+ }
418+
419+ return false ;
404420 }
405421
406422 /**
Original file line number Diff line number Diff line change @@ -342,4 +342,17 @@ public function testRouterIgnoresRouteGroupsWithAnApiPrefix()
342342 }
343343
344344
345+ public function testRequestTargettingAnApiWithNoPrefixOrDomain ()
346+ {
347+ $ this ->router ->get ('/ ' , function () { return 'foo ' ; });
348+
349+ $ this ->router ->api (['version ' => 'v1 ' ], function ()
350+ {
351+ $ this ->router ->get ('foo ' , function () { return 'bar ' ; });
352+ });
353+
354+ $ this ->assertFalse ($ this ->router ->requestTargettingApi (Request::create ('/ ' , 'GET ' )));
355+ }
356+
357+
345358}
You can’t perform that action at this time.
0 commit comments