mirror of
https://github.com/mrclay/minify.git
synced 2025-01-29 19:27:45 +01:00
Simplify identifying file-relative URIs in rewriter
This commit is contained in:
parent
ea866716e7
commit
a2487c7c1a
@ -282,12 +282,8 @@ class Minify_CSS_UriRewriter {
|
||||
? $m[1]
|
||||
: substr($m[1], 1, strlen($m[1]) - 2);
|
||||
}
|
||||
// analyze URI
|
||||
if ('/' !== $uri[0] // root-relative
|
||||
&& !preg_match('~^about\:blank(#.*)?$~', $uri) //about:blank
|
||||
&& false === strpos($uri, '//') // protocol (non-data)
|
||||
&& 0 !== strpos($uri, 'data:') // data protocol
|
||||
) {
|
||||
// if not root/scheme relative and not starts with scheme
|
||||
if (!preg_match('~^(/|[a-z]+\:)~', $uri)) {
|
||||
// URI is file-relative: rewrite depending on options
|
||||
if (self::$_prependPath === null) {
|
||||
$uri = self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks);
|
||||
|
@ -3,14 +3,12 @@
|
||||
@import '/_test_files/bar/foo.css' print;
|
||||
@import '/foo.css' print;
|
||||
@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("/css/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('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(data:image/gif;base64,AAAA);} /* data, should not alter */
|
||||
foo {background:url(about:blank);} /* about:blank, should not alter */
|
||||
foo {background:url(about:blank#tab-a);} /* about:blank with a fragment identifier, should not alter */
|
||||
foo {background:url(foo:bar);} /* scheme, should not alter */
|
||||
|
@ -3,14 +3,12 @@
|
||||
@import 'http://cnd.com/A/bar/foo.css' print;
|
||||
@import 'http://cnd.com/foo.css' print;
|
||||
@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("/css/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://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(data:image/gif;base64,AAAA);} /* data, should not alter */
|
||||
foo {background:url(about:blank);} /* about:blank, should not alter */
|
||||
foo {background:url(about:blank#tab-a);} /* about:blank with a fragment identifier, should not alter */
|
||||
foo {background:url(foo:bar);} /* scheme, should not alter */
|
||||
|
@ -3,12 +3,12 @@
|
||||
@import '//cnd.com/A/bar/foo.css' print;
|
||||
@import '//cnd.com/foo.css' print;
|
||||
@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("/css/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('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(data:image/gif;base64,AAAA);} /* data, should not alter */
|
||||
foo {background:url(foo:bar);} /* scheme, should not alter */
|
||||
|
@ -3,14 +3,12 @@
|
||||
@import '../bar/foo.css' print;
|
||||
@import '../../foo.css' print;
|
||||
@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("/css/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('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(data:image/gif;base64,AAAA);} /* data, should not alter */
|
||||
foo {background:url(about:blank);} /* about:blank, should not alter */
|
||||
foo {background:url(about:blank#tab-a);} /* about:blank with a fragment identifier, should not alter */
|
||||
foo {background:url(foo:bar);} /* scheme, should not alter */
|
||||
|
Loading…
x
Reference in New Issue
Block a user