Skip to content

Commit

Permalink
bug fix #101
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed Jun 21, 2019
1 parent f87abf2 commit 70b45d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/WatchingStrategies/Routes/RouteNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Imanghafoori\HeyMan\WatchingStrategies\Routes;

use Illuminate\Support\Str;

final class RouteNormalizer
{
/**
Expand All @@ -12,11 +14,11 @@ final class RouteNormalizer
public function normalizeAction($actions): array
{
$addNamespace = function ($action) {
if ($action = ltrim($action, '\\')) {
if (Str::startsWith($action, '\\')) {
return $action;
}

return app()->getNamespace().'\\Http\\Controllers\\'.$action;
return app()->getNamespace().'Http\\Controllers\\'.$action;
};

return array_map($addNamespace, $actions);
Expand Down
4 changes: 2 additions & 2 deletions tests/RouteAuthorizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function testRouteNameIsMatchWithPattern()

public function testControllerActionIsAuthorized()
{
Route::get('/welcome', 'HomeController@index')->name('welcome.name');
Route::get('/welcome', '\HomeController@index')->name('welcome.name');

HeyMan::whenYouCallAction('\HomeController@index')->always()->weDenyAccess();
app(StartGuarding::class)->start();
Expand Down Expand Up @@ -205,7 +205,7 @@ public function testRouteNameIsAuthorized34()

public function testControllerActionIsAuthorized878()
{
Route::get('/welcome', 'HomeController@index')->name('welcome.name');
Route::get('/welcome', '\HomeController@index')->name('welcome.name');

HeyMan::whenYouHitRouteName('welcome.Oname')->always()->weDenyAccess();
HeyMan::whenYouCallAction('\HomeController@index')->always()->weDenyAccess();
Expand Down

0 comments on commit 70b45d9

Please sign in to comment.