* Moves URL scanner into lib/urls/reduce (was named incorrectly before).
* Moves URL rebasing & rewriting into lib/urls.
* Fixed issue [#436](https://github.com/jakubpawlowicz/clean-css/issues/436) - refactors URI rewriting.
+* Fixed issue [#448](https://github.com/jakubpawlowicz/clean-css/issues/448) - rebasing no protocol URIs.
[3.2.7 / 2015-05-03](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.6...v3.2.7)
==================
var importedUrl = REMOTE_RESOURCE.test(importedFile) ?
importedFile :
url.resolve(context.relativeTo, importedFile);
+ var originalUrl = importedUrl;
if (importedUrl.indexOf('//') === 0)
importedUrl = 'http:' + importedUrl;
res.on('end', function() {
var importedData = chunks.join('');
if (context.rebase)
- importedData = rewriteUrls(importedData, { toBase: importedUrl }, context);
+ importedData = rewriteUrls(importedData, { toBase: originalUrl }, context);
context.sourceReader.trackSource(importedUrl, importedData);
importedData = context.sourceTracker.store(importedUrl, importedData);
importedData = rebaseMap(importedData, importedUrl);
nock.cleanAll();
}
},
+ 'of a resource without protocol with rebase': {
+ topic: function() {
+ this.reqMocks = nock('http://127.0.0.1')
+ .get('/no-protocol.css')
+ .reply(200, 'a{background:url(image.png)}');
+
+ new CleanCSS().minify('@import url(//127.0.0.1/no-protocol.css);', this.callback);
+ },
+ 'should not raise errors': function(errors, minified) {
+ assert.isNull(errors);
+ },
+ 'should process @import': function(errors, minified) {
+ assert.equal(minified.styles, 'a{background:url(//127.0.0.1/image.png)}');
+ },
+ teardown: function() {
+ assert.isTrue(this.reqMocks.isDone());
+ nock.cleanAll();
+ }
+ },
+ 'of a resource without protocol with rebase to another domain': {
+ topic: function() {
+ this.reqMocks = nock('http://127.0.0.1')
+ .get('/no-protocol.css')
+ .reply(200, 'a{background:url(//127.0.0.2/image.png)}');
+
+ new CleanCSS().minify('@import url(http://127.0.0.1/no-protocol.css);', this.callback);
+ },
+ 'should not raise errors': function(errors, minified) {
+ assert.isNull(errors);
+ },
+ 'should process @import': function(errors, minified) {
+ assert.equal(minified.styles, 'a{background:url(//127.0.0.2/image.png)}');
+ },
+ teardown: function() {
+ assert.isTrue(this.reqMocks.isDone());
+ nock.cleanAll();
+ }
+ },
'of a resource available via POST only': {
topic: function() {
this.reqMocks = nock('http://127.0.0.1')