Skip to content

Commit

Permalink
Remove redundant call to the admin paths config (#5)
Browse files Browse the repository at this point in the history
Change admin URL logic to use the `admin_url()` method on the AdminRootController (#6)
  • Loading branch information
DorsetDigital committed Oct 16, 2018
1 parent d916875 commit 2cbda19
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/CDNMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,18 @@ private function getPrefetchTag()

/**
* Determine whether the website is being viewed from an admin protected area or not
* (shamelessly stolen from https://github.com/silverstripe/silverstripe-subsites)
* (shamelessly based on https://github.com/silverstripe/silverstripe-subsites)
*
* @param HTTPRequest $request
* @return bool
*/
private function getIsAdmin(HTTPRequest $request)
{
$adminPaths = static::config()->get('admin_url_paths');
$adminPaths[] = AdminRootController::config()->get('url_base') . '/';
$adminPath = AdminRootController::admin_url();
$currentPath = rtrim($request->getURL(), '/') . '/';
foreach ($adminPaths as $adminPath) {
if (substr($currentPath, 0, strlen($adminPath)) === $adminPath) {
return true;
}
}
return false;
}
}

0 comments on commit 2cbda19

Please sign in to comment.