1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-04 21:27:52 +02:00
Files
minify/lib/Minify/DebugDetector.php
2019-12-11 17:06:18 +02:00

28 lines
719 B
PHP

<?php
/**
* Detect whether request should be debugged
*/
class Minify_DebugDetector
{
public static function shouldDebugRequest(Minify_Env $env)
{
if ($env->get('debug') !== null) {
return true;
}
$cookieValue = $env->cookie('minifyDebug');
if ($cookieValue) {
foreach (preg_split('/\\s+/', $cookieValue) as $debugUri) {
$pattern = '@' . preg_quote($debugUri, '@') . '@i';
$pattern = str_replace(array('\\*', '\\?'), array('.*', '.'), $pattern);
if (preg_match($pattern, $env->getRequestUri())) {
return true;
}
}
}
return false;
}
}