flex-combo
Advanced tools
Comparing version 0.3.7 to 0.3.8
@@ -10,4 +10,6 @@ var http = require('http') | ||
, beautify = require('./beautify.js').js_beautify | ||
, util = require('util') | ||
, mime = require('mime'); | ||
var debug = require('debug')('flex-combo:debug'); | ||
@@ -43,3 +45,4 @@ var debugInfo = require('debug')('flex-combo:info'); | ||
urlBasedCharset:{}, | ||
fns:[] | ||
fns:[], | ||
forwardPrefix:'' | ||
}; | ||
@@ -205,5 +208,5 @@ | ||
paramStr.toString().replace(/[\n\r]/g, ''); | ||
param = JSON.parse(paramStr); | ||
param = merge(param, JSON.parse(paramStr)); | ||
} | ||
debug(util.inspect(param)); | ||
param.cacheDir = cacheDir; | ||
@@ -218,3 +221,3 @@ if(urls){ | ||
param.prjDir = prjDir; | ||
debug(param); | ||
debug(util.inspect(param)); | ||
@@ -224,2 +227,3 @@ var fileReg = new RegExp(param.supportedFile); | ||
//远程请求的域名不能和访问域名一致,否则会陷入请求循环。 | ||
debug('laiel'); | ||
if(req.headers.host === param.host){ | ||
@@ -243,3 +247,4 @@ return; | ||
var filteredUrl = filterUrl(url); | ||
res.setHeader('Content-Type', mime.lookup(filteredUrl)); | ||
debug('filteredUrl: %s, mime type: %s' ,filteredUrl, mime.lookup(filteredUrl.split('?')[0])); | ||
res.setHeader('Content-Type', mime.lookup(filteredUrl.split('?')[0])); | ||
var singleFileContent = readFromLocal(filteredUrl); | ||
@@ -258,3 +263,4 @@ | ||
//本地没有,从服务器获取 | ||
//本地没有,从服务器获取 | ||
url = param.forwardPrefix + url; | ||
debug('send http request:'+ param.host+ url); | ||
@@ -303,2 +309,4 @@ http.get({host: param.host, port: 80, path: url}, function(resp) { | ||
debugInfo('Networking error:' + e.message); | ||
res.writeHead(404, { 'Content-Type': 'text/html;charset=utf-8'}); | ||
res.end('404 Error, File not found.'); | ||
return; | ||
@@ -326,3 +334,4 @@ }); | ||
if(i === 0 ){ | ||
res.setHeader('Content-Type', mime.lookup(fullPath)); | ||
debug('mime type:%s',mime.lookup(fullPath.split('?')[0])); | ||
res.setHeader('Content-Type', mime.lookup(fullPath.split('?')[0])); | ||
} | ||
@@ -367,3 +376,4 @@ | ||
(function(id) { | ||
http.get({host: param.host, port: 80, path: reqPath + reqArray[id].file}, function(resp) { | ||
var requestPath = param.forwardPrefix + reqPath + reqArray[id].file; | ||
http.get({host: param.host, port: 80, path: requestPath}, function(resp) { | ||
if(resp.statusCode !== 200){ | ||
@@ -383,2 +393,3 @@ debugInfo('Remote not found : %s', 'define request: ', reqPath + reqArray[id].file); | ||
resp.on('end', function() { | ||
debug('response: ' + reqPath + reqArray[id].file); | ||
reqArray[id].ready = true; | ||
@@ -392,7 +403,2 @@ var buff = joinbuffers(buffs); | ||
var fileName = crypto.createHash('md5').update(reqArray[id].file).digest('hex'); | ||
if(isBinFile(reqArray[id].file)){ | ||
reqArray[id].content = buff; | ||
cacheFile('/'+fileName, buff); | ||
return; | ||
} | ||
debugInfo('Remote text:%s', reqPath + reqArray[id].file); | ||
@@ -405,2 +411,3 @@ var charset = isUtf8(buff) ? 'utf8' : 'gbk'; | ||
}).on('error',function(e){ | ||
reqArray[id].ready = true; | ||
debug('Networking error:' + e.message); | ||
@@ -407,0 +414,0 @@ }); |
{ | ||
"name": "flex-combo", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"description": "The Flex-combo is combo tool designed for web front-end developer. It support various kinds of combo format by modify configuration(eg. yahoo combo).", | ||
@@ -5,0 +5,0 @@ "main": "flex-combo.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68003
1504