Fixes #574 - rewriting internal URLs.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 15 May 2015 10:32:01 +0000 (11:32 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 15 May 2015 10:32:01 +0000 (11:32 +0100)
We should not rewrite URLs such as about:config etc.

History.md
lib/urls/rewrite.js
test/integration-test.js

index 5573d6e..1da7df0 100644 (file)
@@ -12,6 +12,7 @@
 * Fixed issue [#448](https://github.com/jakubpawlowicz/clean-css/issues/448) - rebasing no protocol URIs.
 * Fixed issue [#517](https://github.com/jakubpawlowicz/clean-css/issues/517) - turning off color optimizations.
 * Fixed issue [#542](https://github.com/jakubpawlowicz/clean-css/issues/542) - space after closing brace in IE.
+* Fixed issue [#574](https://github.com/jakubpawlowicz/clean-css/issues/574) - rewriting internal URLs.
 
 [3.2.10 / 2015-05-14](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.9...v3.2.10)
 ==================
index af57500..5413500 100644 (file)
@@ -17,6 +17,10 @@ function isEscaped(uri) {
   return uri.indexOf('__ESCAPED_URL_CLEAN_CSS__') === 0;
 }
 
+function isInternal(uri) {
+  return /^\w+:\w+/.test(uri);
+}
+
 function isRemote(uri) {
   return uri.indexOf('http://') === 0 || uri.indexOf('https://') === 0 || uri.indexOf('//') === 0;
 }
@@ -44,7 +48,7 @@ function normalize(uri) {
 }
 
 function rebase(uri, options) {
-  if (isAbsolute(uri) || isSVGMarker(uri) || isEscaped(uri))
+  if (isAbsolute(uri) || isSVGMarker(uri) || isEscaped(uri) || isInternal(uri))
     return uri;
 
   if (options.rebase === false && !isImport(uri))
index 330391a..2138bda 100644 (file)
@@ -1082,6 +1082,10 @@ path")}',
     ],
     'document-local reference': [
       'svg{marker-end:url(#arrow)}', 'svg{marker-end:url(#arrow)}'
+    ],
+    'internal page': [
+      'a{background:url(about:blank)}',
+      'a{background:url(about:blank)}'
     ]
   }, {
     root: process.cwd(),