From: Jakub Pawlowicz Date: Thu, 25 Jun 2015 06:12:04 +0000 (+0100) Subject: Fixes #608 - custom URI protocols handling. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4646fc1a494a5d71ed490ef7374189a0b734adbc;p=clean-css.git Fixes #608 - custom URI protocols handling. We were not treating custom URI protocols as remote ones so they were rewritten as local ones. --- diff --git a/History.md b/History.md index 82747b70..c56a7468 100644 --- a/History.md +++ b/History.md @@ -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) ================== diff --git a/lib/urls/rewrite.js b/lib/urls/rewrite.js index 26b30f2b..bf49f19b 100644 --- a/lib/urls/rewrite.js +++ b/lib/urls/rewrite.js @@ -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) { diff --git a/test/integration-test.js b/test/integration-test.js index 53e78ddb..997ffc9d 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -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': [