Comparing version 1.0.2 to 1.0.3
exports.serverRoot = 'D:\\Projects\\static-trunk'; | ||
exports.serverRoot = 'd:\\htdocs\\tudou.com\\static'; | ||
exports.map = [ | ||
['http://js.tudouui.com/js/lib/tuilib2.js', exports.serverRoot + '/js/lib/tuilib2_src.js'], | ||
['http://jstest.tudouui.com/js/lib/tuilib2.js', exports.serverRoot + '/js/lib/tuilib2_src.js'], | ||
['http://css.tudouui.com/skin/__g/__g.css', exports.serverRoot + '/skin/__g/__g_src.css'], | ||
['http://csstest.tudouui.com/skin/__g/__g.css', exports.serverRoot + '/skin/__g/__g_src.css'], | ||
//线上环境 | ||
//['http://js.tudouui.com/js/lib/tuilib2.js', exports.serverRoot + '/js/lib/tuilib2_src.js'], | ||
//['http://jstest.tudouui.com/js/page/play/v4/main.js', exports.serverRoot + '/js/page/play/v4/main_src.js'], | ||
//['http://js.tudouui.com/js/fn/flashloader2.js', exports.serverRoot + '/js/fn/flashloader2_src.js'], | ||
//['http://js.tudouui.com/js/page/play/v4/main.js', exports.serverRoot + '/js/page/play/v4/main_src.js'], | ||
//['http://js.tudouui.com/js/page/play/v4/comment.js', exports.serverRoot + '/js/page/play/v4/comment_src.js'], | ||
//['http://css.tudouui.com/skin/play/v4/play.css', exports.serverRoot + '/skin/play/v4/play_src.css'], | ||
//wwwtest环境 | ||
//['http://jstest.tudouui.com/js/lib/tuilib2.js', exports.serverRoot + '/js/lib/tuilib2_src.js'], | ||
// ['http://jstest.tudouui.com/js/fn/flashloader2.js', exports.serverRoot + '/js/fn/flashloader2_src.js'], | ||
// ['http://jstest.tudouui.com/js/page/play/v4/main.js', exports.serverRoot + '/js/page/play/v4/main_src.js'], | ||
// ['http://jstest.tudouui.com/js/page/play/v4/comment.js', exports.serverRoot + '/js/page/play/v4/comment_src.js'], | ||
// ['http://csstest.tudouui.com/skin/play/v4/play.css', exports.serverRoot + '/skin/play/v4/play_src.css'], | ||
// ['http://csstest.tudouui.com/skin/play/v4/img/pcapp.png', exports.serverRoot + '/skin/play/v4/img/pcapp.png'], | ||
['http://jstest.tudouui.com/bin/lingtong/PortalPlayer.swf', 'http://10.5.28.37/ad/tudouPlayer.swf'], | ||
//['http://jstest.tudouui.com/js/lib/tuilib2.js', 'http://js.tudouui.com/js/lib/tuilib2.js'], | ||
]; | ||
@@ -10,0 +24,0 @@ |
29
main.js
@@ -87,20 +87,29 @@ | ||
if (!/^https?:\/\//.test(to)) { | ||
// rewrite | ||
if(from !== to){ | ||
console.log('[rewrite] ' + url + ' -> ' + to); | ||
if (merge) { | ||
merge.call(me, to, function(contentType, buffer) { | ||
setResponse(response, contentType, buffer); | ||
}); | ||
// local file | ||
if (!/^https?:\/\//.test(to)) { | ||
if (merge) { | ||
merge.call(me, to, function(contentType, buffer) { | ||
setResponse(response, contentType, buffer); | ||
}); | ||
return; | ||
} | ||
var contentType = Mime.lookup(to); | ||
var buffer = Util.readFileSync(to); | ||
setResponse(response, contentType, buffer); | ||
return; | ||
} | ||
var contentType = Mime.lookup(to); | ||
var buffer = Util.readFileSync(to); | ||
setResponse(response, contentType, buffer); | ||
// remote URL | ||
request.pipe(Request(to)).pipe(response); | ||
return; | ||
} | ||
var parsed = Url.parse(to); | ||
// no rewrite | ||
var parsed = Url.parse(url); | ||
@@ -107,0 +116,0 @@ var proxy = new HttpProxy.HttpProxy({ |
{ | ||
"name": "hrt", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "HTTP Rewrite Tool for Frontend", | ||
@@ -5,0 +5,0 @@ "author": "Longhao Luo <lhluo@tudou.com>", |
@@ -71,3 +71,3 @@ | ||
if (/https?:\/\//.test(to)) { | ||
if (/^https?:\/\//.test(to)) { | ||
to = start + to + end; | ||
@@ -74,0 +74,0 @@ return to; |
1156980
23933