Skip to content

Commit fff9d07

Browse files
authored
Check for ignored urls
1 parent 1189ebc commit fff9d07

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/Middleware/InjectDebugbar.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ class InjectDebugbar
2525
*/
2626
protected $debugbar;
2727

28+
/**
29+
* The URIs that should be excluded.
30+
*
31+
* @var array
32+
*/
33+
protected $except = [];
34+
2835
/**
2936
* Create a new middleware instance.
3037
*
@@ -35,6 +42,7 @@ public function __construct(Container $container, LaravelDebugbar $debugbar)
3542
{
3643
$this->container = $container;
3744
$this->debugbar = $debugbar;
45+
$this->except = config('debugbar.except') ?: [];
3846
}
3947

4048
/**
@@ -46,7 +54,7 @@ public function __construct(Container $container, LaravelDebugbar $debugbar)
4654
*/
4755
public function handle($request, Closure $next)
4856
{
49-
if (!$this->debugbar->isEnabled()) {
57+
if (!$this->debugbar->isEnabled() || $this->inExceptArray($request)) {
5058
return $next($request);
5159
}
5260

@@ -91,4 +99,25 @@ protected function handleException($passable, Exception $e)
9199

92100
return $handler->render($passable, $e);
93101
}
102+
103+
/**
104+
* Determine if the request has a URI that should be ignored.
105+
*
106+
* @param \Illuminate\Http\Request $request
107+
* @return bool
108+
*/
109+
protected function inExceptArray($request)
110+
{
111+
foreach ($this->except as $except) {
112+
if ($except !== '/') {
113+
$except = trim($except, '/');
114+
}
115+
116+
if ($request->is($except)) {
117+
return true;
118+
}
119+
}
120+
121+
return false;
122+
}
94123
}

0 commit comments

Comments
 (0)