mirror of
https://github.com/thinkjs/thinkjs.git
synced 2026-01-25 14:42:47 +00:00
修复静态资源下的.html文件定位的bug
This commit is contained in:
parent
a019da8f30
commit
290e99cdba
@ -9,7 +9,7 @@ module.exports = {
|
||||
pathname_prefix: "", //不解析的pathname前缀
|
||||
app_tag_on: true, //是否支持标签功能
|
||||
url_resource_on: true, //是否监听静态资源类请求
|
||||
url_resource_reg: /^resource\//, //判断是否是静态资源的正则
|
||||
url_resource_reg: /^(resource\/|favicon\.ico)/, //判断是否是静态资源的正则
|
||||
post_json_content_type: ["application/json"], //post数据为json时的content-type
|
||||
url_route_on: true, //开启自定义路由功能
|
||||
url_html_suffix: ".html", //url后缀,这样可以做到伪静态,对搜索引擎更友好
|
||||
|
||||
@ -15,12 +15,16 @@ module.exports = Behavior(function(){
|
||||
if (!RESOURCE_PATH || !this.options.url_resource_on || !this.http.pathname) {
|
||||
return false;
|
||||
};
|
||||
var pathname = this.http.pathname;
|
||||
if (pathname.indexOf('/') === 0) {
|
||||
pathname = pathname.substr(1);
|
||||
};
|
||||
var reg = C('url_resource_reg');
|
||||
//通过正则判断是否是静态资源请求
|
||||
if (!reg.test(this.http.pathname)) {
|
||||
if (!reg.test(pathname)) {
|
||||
return false;
|
||||
};
|
||||
var file = RESOURCE_PATH + "/" + this.http.pathname;
|
||||
var file = RESOURCE_PATH + "/" + pathname;
|
||||
var res = this.http.res;
|
||||
if (fs.existsSync(file)) {
|
||||
var contentType = mime.lookup(file);
|
||||
@ -34,6 +38,7 @@ module.exports = Behavior(function(){
|
||||
res.statusCode = 404;
|
||||
res.end();
|
||||
}
|
||||
//返回一个pendding promise, 不让后续执行
|
||||
return getDefer().promise;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,9 +32,9 @@ var Dispatcher = module.exports = Class(function(){
|
||||
},
|
||||
run: function(){
|
||||
var self = this;
|
||||
self.parsePathName();
|
||||
return tag("path_info", this.http).then(function(){
|
||||
return self.resourceCheck();
|
||||
return self.resourceCheck().then(function(){
|
||||
self.parsePathName();
|
||||
return tag("path_info", self.http);
|
||||
}).then(function(){
|
||||
return self.routeCheck();
|
||||
}).then(function(flag){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user