Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improved issue 170

  • Loading branch information...
commit b8a8ae69e9018397f0a3cc29b4853a4e58956245 1 parent 72e7b52
@mrclay mrclay authored committed
View
1  .gitignore
@@ -2,3 +2,4 @@
# /
/test
/docs
+.idea/
View
8 min/builder/bm2.js
@@ -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;
})();
View
14 min/index.php
@@ -36,18 +36,8 @@
}
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) {
View
26 min/lib/Minify/DebugDetector.php
@@ -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;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.