Skip to content

Commit

Permalink
don't apply middleware for assets
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Mar 15, 2024
1 parent cf82349 commit 4e82107
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion code/Middleware/DebugBarMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,19 @@ protected function afterRequest(HTTPRequest $request, HTTPResponse $response)
if (!$debugbar) {
return;
}

// Don't apply to assets
$dir = defined('ASSETS_DIR') ? ASSETS_DIR : 'assets';
if (strpos($request->getURL(), "$dir/") === 0) {
return;
}

DebugBar::setRequest($request);

// All queries have been displayed
if (DebugBar::getShowQueries()) {
exit();
}

$script = DebugBar::renderDebugBar();

// If the bar is not renderable, return early
Expand All @@ -106,6 +112,7 @@ protected function afterRequest(HTTPRequest $request, HTTPResponse $response)

// Inject init script into the HTML response
$body = (string)$response->getBody();

if (strpos($body, '</body>') !== false) {
$customScripts = '';
if (DebugBar::$suppressJquery) {
Expand Down

0 comments on commit 4e82107

Please sign in to comment.