From: Daniel Darabos Date: Tue, 26 Aug 2014 12:10:48 +0000 (+0200) Subject: Fixes #345 - disable rebasing for document-relative URL. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f5fd20edf6d1d8f74525d1d9f511b974cc52799e;p=clean-css.git Fixes #345 - disable rebasing for document-relative URL. --- diff --git a/History.md b/History.md index 3b338546..49fe1eb4 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,7 @@ [2.2.15 / 2014-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.14...v2.2.15) ================== +* Fixed issue [#345](https://github.com/GoalSmashers/clean-css/issues/345) - URL rebasing for document relative ones. * Fixed issue [#343](https://github.com/GoalSmashers/clean-css/issues/343) - too aggressive rgba/hsla minification. [2.2.14 / 2014-08-25](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.13...v2.2.14) diff --git a/lib/images/url-rewriter.js b/lib/images/url-rewriter.js index 1788b881..a13842e4 100644 --- a/lib/images/url-rewriter.js +++ b/lib/images/url-rewriter.js @@ -33,6 +33,7 @@ module.exports = { _rebased: function(resource, options) { var specialUrl = resource[0] == '/' || + resource[0] == '#' || resource.substring(resource.length - 4) == '.css' || resource.indexOf('data:') === 0 || /^https?:\/\//.exec(resource) !== null || diff --git a/test/unit-test.js b/test/unit-test.js index 4002ee3a..42b14fa2 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -932,6 +932,9 @@ path")}', 'absolute @import': [ '@import url(/test/data/partials-relative/base.css);', 'a{background:url(test/data/partials/extra/down.gif) no-repeat}' + ], + 'document-local reference': [ + 'svg{marker-end:url(#arrow)}', 'svg{marker-end:url(#arrow)}' ] }), 'urls rewriting - root but no target': cssContext({ @@ -946,6 +949,9 @@ path")}', 'absolute @import': [ '@import url(/test/data/partials-relative/base.css);', 'a{background:url(/test/data/partials/extra/down.gif) no-repeat}' + ], + 'document-local reference': [ + 'svg{marker-end:url(#arrow)}', 'svg{marker-end:url(#arrow)}' ] }, { root: process.cwd(), @@ -963,6 +969,9 @@ path")}', 'absolute @import': [ '@import url(/test/data/partials-relative/base.css);', 'a{background:url(test/data/partials/extra/down.gif) no-repeat}' + ], + 'document-local reference': [ + 'svg{marker-end:url(#arrow)}', 'svg{marker-end:url(#arrow)}' ] }, { target: path.join(process.cwd(), 'test.css'), @@ -980,6 +989,9 @@ path")}', 'absolute @import': [ '@import url(/test/data/partials-relative/base.css);', 'a{background:url(test/data/partials/extra/down.gif) no-repeat}' + ], + 'document-local reference': [ + 'svg{marker-end:url(#arrow)}', 'svg{marker-end:url(#arrow)}' ] }, { target: process.cwd(), @@ -997,6 +1009,9 @@ path")}', 'absolute @import': [ '@import url(/test/data/partials-relative/base.css);', 'a{background:url(/test/data/partials/extra/down.gif) no-repeat}' + ], + 'document-local reference': [ + 'svg{marker-end:url(#arrow)}', 'svg{marker-end:url(#arrow)}' ] }, { root: process.cwd(),