看这段文档,express 4 对路由正则表达式的支持变弱了?
发布于 8 年前 作者 yuanjl 3285 次浏览 来自 问答

###Compatibility with Express <= 4.x

Path-To-RegExp breaks compatibility with Express <= 4.x:

  • No longer a direct conversion to a RegExp with sugar on top - it’s a path matcher with named and unnamed matching groups
  • It’s unlikely you previously abused this feature, it’s rare and you could always use a RegExp instead
  • All matching RegExp special characters can be used in a matching group. E.g. /:user(.*)
  • Other RegExp features are not support - no nested matching groups, non-capturing groups or look aheads
  • Parameters have suffixes that augment meaning - , + and ?. E.g. /:user

来源

回到顶部