mirror of
https://github.com/mrclay/minify.git
synced 2025-08-12 09:05:08 +02:00
improved issue 170
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
# /
|
||||
/test
|
||||
/docs
|
||||
.idea/
|
@@ -1,15 +1,15 @@
|
||||
javascript:(function(){
|
||||
var d = document
|
||||
,c = d.cookie
|
||||
,m = c.match(/\bminDebug=([^; ]+)/)
|
||||
,m = c.match(/\bminifyDebug=([^; ]+)/)
|
||||
,v = m ? decodeURIComponent(m[1]) : ''
|
||||
,p = prompt('Debug Minify URIs on ' + location.hostname + ' which contain:'
|
||||
+ '\n(empty for none, space = OR)', v)
|
||||
+ '\n(empty for none, space = OR, * = any string, ? = any char)', v)
|
||||
;
|
||||
if (p === null) return;
|
||||
p = p.replace(/^\s+|\s+$/, '');
|
||||
v = (p === '')
|
||||
? 'minDebug=; expires=Fri, 27 Jul 2001 02:47:11 UTC; path=/'
|
||||
: 'minDebug=' + encodeURIComponent(p) + '; path=/';
|
||||
? 'minifyDebug=; expires=Fri, 27 Jul 2001 02:47:11 UTC; path=/'
|
||||
: 'minifyDebug=' + encodeURIComponent(p) + '; path=/';
|
||||
d.cookie = v;
|
||||
})();
|
@@ -36,18 +36,8 @@ foreach ($min_symlinks as $uri => $target) {
|
||||
}
|
||||
|
||||
if ($min_allowDebugFlag) {
|
||||
if (! empty($_COOKIE['minDebug'])) {
|
||||
foreach (preg_split('/\\s+/', $_COOKIE['minDebug']) as $debugUri) {
|
||||
if (false !== strpos($_SERVER['REQUEST_URI'], $debugUri)) {
|
||||
$min_serveOptions['debug'] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// allow GET to override
|
||||
if (isset($_GET['debug'])) {
|
||||
$min_serveOptions['debug'] = true;
|
||||
}
|
||||
require_once 'Minify/DebugDetector.php';
|
||||
$min_serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
|
||||
}
|
||||
|
||||
if ($min_errorLogger) {
|
||||
|
26
min/lib/Minify/DebugDetector.php
Normal file
26
min/lib/Minify/DebugDetector.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Detect whether request should be debugged
|
||||
*
|
||||
* @package Minify
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_DebugDetector {
|
||||
public static function shouldDebugRequest($cookie, $get, $requestUri)
|
||||
{
|
||||
if (isset($get['debug'])) {
|
||||
return true;
|
||||
}
|
||||
if (! empty($cookie['minifyDebug'])) {
|
||||
foreach (preg_split('/\\s+/', $cookie['minifyDebug']) as $debugUri) {
|
||||
$pattern = '@' . preg_quote($debugUri, '@') . '@i';
|
||||
$pattern = str_replace(array('\\*', '\\?'), array('.*', '.'), $pattern);
|
||||
if (preg_match($pattern, $requestUri)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user