Skip to content

Instantly share code, notes, and snippets.

@wzrdtales
Last active March 16, 2016 13:04
Show Gist options
  • Save wzrdtales/621ff62d38bb94737215 to your computer and use it in GitHub Desktop.
Save wzrdtales/621ff62d38bb94737215 to your computer and use it in GitHub Desktop.
clean-css broken proxy testcase
'use strict';
var CleanCSS = require( './' ),
httpProxy = require( 'http-proxy' ),
http = require( 'http' ),
https = require( 'https' ),
url = require( 'url' );
var proxy = httpProxy.createProxyServer();
var proxyServer = http.createServer((req, res) => {
var get = (req.url.indexOf('http://') === 0) ? http.get : https.get;
get(req.url,
( response ) => {
response.on('data', c => res.write(c) );
response.on('end', _ => res.end( ) );
} );
});
proxyServer.listen(8080, _ => {
var options = {
inliner: {
request: {
hostname: '127.0.0.1',
port: 8080
}
}
};
//socket hang up
new CleanCSS(options).minify(
'@import url(https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic&subset=latin);a{color:red}',
( err, data ) => {
console.log( err, data.styles );
});
//without https everything is fine
new CleanCSS(options).minify(
'@import url(http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic&subset=latin);a{color:red}',
( err, data ) => {
console.log( err, data.styles );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment