@@ -490,6 +490,59 @@ public function testTrailingSlashIsTrimmedWhenMatchingCachedRoutes()
490490 $ this ->assertSame ('foo ' , $ this ->collection ()->match ($ request )->getName ());
491491 }
492492
493+ public function testRouteWithSamePathAndSameMethodButDiffDomainNameWithOptionsMethod ()
494+ {
495+ $ routes = [
496+ 'foo_domain ' => $ this ->newRoute ('GET ' , 'same/path ' , [
497+ 'uses ' => 'FooController@index ' ,
498+ 'as ' => 'foo ' ,
499+ 'domain ' => 'foo.localhost ' ,
500+ ]),
501+ 'bar_domain ' => $ this ->newRoute ('GET ' , 'same/path ' , [
502+ 'uses ' => 'BarController@index ' ,
503+ 'as ' => 'bar ' ,
504+ 'domain ' => 'bar.localhost ' ,
505+ ]),
506+ 'no_domain ' => $ this ->newRoute ('GET ' , 'same/path ' , [
507+ 'uses ' => 'BarController@index ' ,
508+ 'as ' => 'no_domain ' ,
509+ ]),
510+ ];
511+
512+ $ this ->routeCollection ->add ($ routes ['foo_domain ' ]);
513+ $ this ->routeCollection ->add ($ routes ['bar_domain ' ]);
514+ $ this ->routeCollection ->add ($ routes ['no_domain ' ]);
515+
516+ $ expectedMethods = [
517+ 'OPTIONS ' ,
518+ ];
519+
520+ $ this ->assertSame ($ expectedMethods , $ this ->collection ()->match (
521+ Request::create ('http://foo.localhost/same/path ' , 'OPTIONS ' )
522+ )->methods );
523+
524+ $ this ->assertSame ($ expectedMethods , $ this ->collection ()->match (
525+ Request::create ('http://bar.localhost/same/path ' , 'OPTIONS ' )
526+ )->methods );
527+
528+ $ this ->assertSame ($ expectedMethods , $ this ->collection ()->match (
529+ Request::create ('http://no.localhost/same/path ' , 'OPTIONS ' )
530+ )->methods );
531+
532+ $ this ->assertEquals ([
533+ 'HEAD ' => [
534+ 'foo.localhost/same/path ' => $ routes ['foo_domain ' ],
535+ 'bar.localhost/same/path ' => $ routes ['bar_domain ' ],
536+ 'same/path ' => $ routes ['no_domain ' ],
537+ ],
538+ 'GET ' => [
539+ 'foo.localhost/same/path ' => $ routes ['foo_domain ' ],
540+ 'bar.localhost/same/path ' => $ routes ['bar_domain ' ],
541+ 'same/path ' => $ routes ['no_domain ' ],
542+ ],
543+ ], $ this ->collection ()->getRoutesByMethod ());
544+ }
545+
493546 /**
494547 * Create a new Route object.
495548 *
0 commit comments