1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-06 14:16:28 +02:00

Merge branch 'joec4i-master'

This commit is contained in:
Steve Clay
2014-02-04 10:31:37 -05:00
5 changed files with 18 additions and 21 deletions

View File

@@ -282,11 +282,8 @@ class Minify_CSS_UriRewriter {
? $m[1] ? $m[1]
: substr($m[1], 1, strlen($m[1]) - 2); : substr($m[1], 1, strlen($m[1]) - 2);
} }
// analyze URI // if not root/scheme relative and not starts with scheme
if ('/' !== $uri[0] // root-relative if (!preg_match('~^(/|[a-z]+\:)~', $uri)) {
&& false === strpos($uri, '//') // protocol (non-data)
&& 0 !== strpos($uri, 'data:') // data protocol
) {
// URI is file-relative: rewrite depending on options // URI is file-relative: rewrite depending on options
if (self::$_prependPath === null) { if (self::$_prependPath === null) {
$uri = self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks); $uri = self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks);

View File

@@ -3,12 +3,12 @@
@import '/_test_files/bar/foo.css' print; @import '/_test_files/bar/foo.css' print;
@import '/foo.css' print; @import '/foo.css' print;
@import '/css/foo.css'; /* abs, should not alter */ @import '/css/foo.css'; /* abs, should not alter */
@import 'http://foo.com/css/foo.css'; /* abs, should not alter */ @import 'http://foo.com/css/foo.css'; /* scheme, should not alter */
@import url(/_test_files/foo.css) tv, projection; @import url(/_test_files/foo.css) tv, projection;
@import url("/css/foo.css"); /* abs, should not alter */ @import url("/css/foo.css"); /* abs, should not alter */
@import url(/css2/foo.css); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */
@import url(data:image/gif;base64,AAAA); /* data, should not alter */ @import url(foo:bar); /* scheme, should not alter */
foo {background:url('/_test_files/css_uriRewriter/bar/foo.png')} foo {background:url('/_test_files/css_uriRewriter/bar/foo.png')}
foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */ foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */
foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */
foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */ foo {background:url(foo:bar);} /* scheme, should not alter */

View File

@@ -3,12 +3,12 @@
@import 'http://cnd.com/A/bar/foo.css' print; @import 'http://cnd.com/A/bar/foo.css' print;
@import 'http://cnd.com/foo.css' print; @import 'http://cnd.com/foo.css' print;
@import '/css/foo.css'; /* abs, should not alter */ @import '/css/foo.css'; /* abs, should not alter */
@import 'http://foo.com/css/foo.css'; /* abs, should not alter */ @import 'http://foo.com/css/foo.css'; /* scheme, should not alter */
@import url(http://cnd.com/A/foo.css) tv, projection; @import url(http://cnd.com/A/foo.css) tv, projection;
@import url("/css/foo.css"); /* abs, should not alter */ @import url("/css/foo.css"); /* abs, should not alter */
@import url(/css2/foo.css); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */
@import url(data:image/gif;base64,AAAA); /* data, should not alter */ @import url(foo:bar); /* scheme, should not alter */
foo {background:url('http://cnd.com/A/B/bar/foo.png')} foo {background:url('http://cnd.com/A/B/bar/foo.png')}
foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */ foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */
foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */
foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */ foo {background:url(foo:bar);} /* scheme, should not alter */

View File

@@ -3,12 +3,12 @@
@import '//cnd.com/A/bar/foo.css' print; @import '//cnd.com/A/bar/foo.css' print;
@import '//cnd.com/foo.css' print; @import '//cnd.com/foo.css' print;
@import '/css/foo.css'; /* abs, should not alter */ @import '/css/foo.css'; /* abs, should not alter */
@import 'http://foo.com/css/foo.css'; /* abs, should not alter */ @import 'http://foo.com/css/foo.css'; /* scheme, should not alter */
@import url(//cnd.com/A/foo.css) tv, projection; @import url(//cnd.com/A/foo.css) tv, projection;
@import url("/css/foo.css"); /* abs, should not alter */ @import url("/css/foo.css"); /* abs, should not alter */
@import url(/css2/foo.css); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */
@import url(data:image/gif;base64,AAAA); /* data, should not alter */ @import url(foo:bar); /* scheme, should not alter */
foo {background:url('//cnd.com/A/B/bar/foo.png')} foo {background:url('//cnd.com/A/B/bar/foo.png')}
foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */ foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */
foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */
foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */ foo {background:url(foo:bar);} /* scheme, should not alter */

View File

@@ -3,12 +3,12 @@
@import '../bar/foo.css' print; @import '../bar/foo.css' print;
@import '../../foo.css' print; @import '../../foo.css' print;
@import '/css/foo.css'; /* abs, should not alter */ @import '/css/foo.css'; /* abs, should not alter */
@import 'http://foo.com/css/foo.css'; /* abs, should not alter */ @import 'http://foo.com/css/foo.css'; /* scheme, should not alter */
@import url(../foo.css) tv, projection; @import url(../foo.css) tv, projection;
@import url("/css/foo.css"); /* abs, should not alter */ @import url("/css/foo.css"); /* abs, should not alter */
@import url(/css2/foo.css); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */
@import url(data:image/gif;base64,AAAA); /* data, should not alter */ @import url(foo:bar); /* scheme, should not alter */
foo {background:url('bar/foo.png')} foo {background:url('bar/foo.png')}
foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */ foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */
foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */
foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */ foo {background:url(foo:bar);} /* scheme, should not alter */