opnform/app/Http/Middleware/TrimStrings.php

43 lines
905 B
PHP
Raw Normal View History

2022-09-20 19:59:52 +00:00
<?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
2024-02-23 10:54:12 +00:00
*
2022-09-20 19:59:52 +00:00
* @var string[]
*/
protected $exceptUrls = [
2024-02-23 10:54:12 +00:00
'/\/api\/forms\/(.*)\/answer/',
2022-09-20 19:59:52 +00:00
];
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);
}
}