Fixes #608 - custom URI protocols handling.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Thu, 25 Jun 2015 06:12:04 +0000 (07:12 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 1 Jul 2015 12:43:04 +0000 (13:43 +0100)
We were not treating custom URI protocols as remote ones so
they were rewritten as local ones.

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

index 82747b7..c56a746 100644 (file)
@@ -3,6 +3,11 @@
 
 * Fixed issue [#599](https://github.com/jakubpawlowicz/clean-css/issues/599) - support for inlined source maps.
 
+[3.3.5 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.4...3.3)
+==================
+
+* Fixed issue [#608](https://github.com/jakubpawlowicz/clean-css/issues/608) - custom URI protocols handling.
+
 [3.3.4 / 2015-06-24](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.3...v3.3.4)
 ==================
 
index 26b30f2..bf49f19 100644 (file)
@@ -22,7 +22,7 @@ function isInternal(uri) {
 }
 
 function isRemote(uri) {
-  return uri.indexOf('http://') === 0 || uri.indexOf('https://') === 0 || uri.indexOf('//') === 0;
+  return /^[^:]+?:\/\//.test(uri) || uri.indexOf('//') === 0;
 }
 
 function isImport(uri) {
index 53e78dd..997ffc9 100644 (file)
@@ -1309,6 +1309,18 @@ vows.describe('integration tests')
       ]
     })
   )
+  .addBatch(
+    optimizerContext('urls custom protocol and url rewriting', {
+      'simple': [
+        'a{background:url(app://abc.png)}',
+        'a{background:url(app://abc.png)}'
+      ],
+      'complex': [
+        'a{background:url(git+ssh2://abc.png)}',
+        'a{background:url(git+ssh2://abc.png)}'
+      ]
+    }, { root: process.cwd(), relativeTo: process.cwd() })
+  )
   .addBatch(
     optimizerContext('urls whitespace in compatibility mode', {
       'keeps spaces as they are': [