Closed darkforest42 closed 7 years ago
这样试试:
// company.js
exports.index = async function(){
// controller
}
exports.index.__regular__ = /^\/company(?:\/|$)/
正则有问题 模块path-to-regexp报错了 SyntaxError: Invalid regular expression: /^\/company\/index\/\^\/company((?:?\:\ \/|\$))(?:\/(?=$))?$/: Nothing to repeat 然后我改成/^\/company(\/(\S)+)?/,访问http://127.0.0.1/company/development, Not Found
我这儿没有问题:
// company.js
exports.index = async function(){
this.body = 'test'
}
exports.index.__regular__ = /^\/company(?:\/|$)/
Oh,原来是我没有更新代码 你有一次commit : update添加正则表达式路由的支持
比如说我要生成这样一个路由: http://127.0.0.1/company/development company是controller目录下的一个路由文件,而后面的development是不确定的分类,我本想在company.js下设置regular为正则匹配, 结果正则并不起作用