Remove redundant middleware

This commit is contained in:
Pig Fang 2019-04-06 23:16:37 +08:00
parent 298b6edf66
commit 23a9f018ca
2 changed files with 0 additions and 25 deletions

View File

@ -27,7 +27,6 @@ class Kernel extends HttpKernel
protected $middlewareGroups = [ protected $middlewareGroups = [
'web' => [ 'web' => [
\App\Http\Middleware\EncryptCookies::class, \App\Http\Middleware\EncryptCookies::class,
\App\Http\Middleware\RedirectIfUrlEndsWithSlash::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class, \Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class,

View File

@ -1,24 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Support\Str;
class RedirectIfUrlEndsWithSlash
{
public function handle($request, \Closure $next)
{
if (substr($request->getRequestUri(), -1) == '/') {
$baseUrl = $request->getBaseUrl();
// Try to remove slash at the end of current url
$newUrl = substr($request->getRequestUri(), 0, -1);
if ($newUrl != $baseUrl) {
return redirect(Str::replaceLast($baseUrl, '', $newUrl));
}
}
return $next($request);
}
}