mirror of
https://github.com/mrclay/minify.git
synced 2025-08-13 09:34:54 +02:00
improved issue 170
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
# /
|
# /
|
||||||
/test
|
/test
|
||||||
/docs
|
/docs
|
||||||
|
.idea/
|
@@ -1,15 +1,15 @@
|
|||||||
javascript:(function(){
|
javascript:(function(){
|
||||||
var d = document
|
var d = document
|
||||||
,c = d.cookie
|
,c = d.cookie
|
||||||
,m = c.match(/\bminDebug=([^; ]+)/)
|
,m = c.match(/\bminifyDebug=([^; ]+)/)
|
||||||
,v = m ? decodeURIComponent(m[1]) : ''
|
,v = m ? decodeURIComponent(m[1]) : ''
|
||||||
,p = prompt('Debug Minify URIs on ' + location.hostname + ' which contain:'
|
,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;
|
if (p === null) return;
|
||||||
p = p.replace(/^\s+|\s+$/, '');
|
p = p.replace(/^\s+|\s+$/, '');
|
||||||
v = (p === '')
|
v = (p === '')
|
||||||
? 'minDebug=; expires=Fri, 27 Jul 2001 02:47:11 UTC; path=/'
|
? 'minifyDebug=; expires=Fri, 27 Jul 2001 02:47:11 UTC; path=/'
|
||||||
: 'minDebug=' + encodeURIComponent(p) + '; path=/';
|
: 'minifyDebug=' + encodeURIComponent(p) + '; path=/';
|
||||||
d.cookie = v;
|
d.cookie = v;
|
||||||
})();
|
})();
|
@@ -36,18 +36,8 @@ foreach ($min_symlinks as $uri => $target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($min_allowDebugFlag) {
|
if ($min_allowDebugFlag) {
|
||||||
if (! empty($_COOKIE['minDebug'])) {
|
require_once 'Minify/DebugDetector.php';
|
||||||
foreach (preg_split('/\\s+/', $_COOKIE['minDebug']) as $debugUri) {
|
$min_serveOptions['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
|
||||||
if (false !== strpos($_SERVER['REQUEST_URI'], $debugUri)) {
|
|
||||||
$min_serveOptions['debug'] = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// allow GET to override
|
|
||||||
if (isset($_GET['debug'])) {
|
|
||||||
$min_serveOptions['debug'] = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($min_errorLogger) {
|
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