Comparing version 1.0.4 to 1.0.5
40
main.js
@@ -83,29 +83,31 @@ | ||
var serverRoot = /^https?:\/\//.test(url) ? '' : CONFIG.serverRoot; | ||
if (from) { | ||
var serverRoot = /^https?:\/\//.test(url) ? '' : CONFIG.serverRoot; | ||
var to = Util.rewrite(map, from, serverRoot); | ||
var to = Util.rewrite(map, from, serverRoot); | ||
// rewrite | ||
if(from !== to){ | ||
Util.info('[rewrite] ' + url + ' -> ' + to); | ||
// rewrite | ||
if(from !== to){ | ||
Util.info('[rewrite] ' + url + ' -> ' + to); | ||
// local file | ||
if (!/^https?:\/\//.test(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; | ||
} | ||
// remote URL | ||
request.pipe(Request(to)).pipe(response); | ||
return; | ||
} | ||
@@ -112,0 +114,0 @@ |
{ | ||
"name": "hrt", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "HTTP Rewrite Tool for Frontend", | ||
@@ -5,0 +5,0 @@ "author": "Longhao Luo <lhluo@tudou.com>", |
1157295
23947