Initial commit
This commit is contained in:
41
app/Http/Middleware/TrimStrings.php
Normal file
41
app/Http/Middleware/TrimStrings.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* The route name where this shouldn't be applied
|
||||
* @var string[]
|
||||
*/
|
||||
protected $exceptUrls = [
|
||||
'/\/api\/forms\/(.*)\/answer/'
|
||||
];
|
||||
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
// Check if URL matches
|
||||
foreach ($this->exceptUrls as $urlRegex) {
|
||||
$matches = null;
|
||||
preg_match($urlRegex, $request->url(), $matches);
|
||||
|
||||
if (count($matches)) {
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::handle($request, $next);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user