Skip to content

Commit

Permalink
Improve the routes
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckyCyborg committed Jul 13, 2019
1 parent 536b9ce commit cdb4cea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/Routes/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@
// Register the route for assets from Packages, Modules and Themes.
$dispatcher->route('packages/(:any)/(:any)/(:all)', function (Request $request, $vendor, $package, $path) use ($dispatcher)
{
if (is_null($packagePath = $dispatcher->getPackagePath($vendor, $package))) {
if (empty($basePath = $dispatcher->getPackagePath($vendor, $package))) {
return Response::make('File Not Found', 404);
}

return $packagePath .str_replace('/', DS, $path);
return $basePath .DS .str_replace('/', DS, $path);
});

// Register the route for assets from Vendor.
$dispatcher->route('vendor/(:all)', function (Request $request, $path) use ($dispatcher)
{
$basePath = BASEPATH .'vendor' .DS;

if (! Str::startsWith($path, $dispatcher->getVendorPaths())) {
return Response::make('File Not Found', 404);
}

return BASEPATH .'vendor' .DS .str_replace('/', DS, $path);
return $basePath .DS .str_replace('/', DS, $path);
});

0 comments on commit cdb4cea

Please sign in to comment.