简体   繁体   English

排除Express.js路由中的单词列表

[英]Exclude list of words in Express.js route

I have something like this in Express.js Framework 我在Express.js框架中有这样的东西

app.post('/:username/:slug', user.fn); app.post('/:username /:slug',user.fn);

Now I want to come up with a regular expression that checks if slug is equal to certain words (profile, album, etc.) , pass to the next route and don't capture the slug and username. 现在我想提出一个正则表达式来检查slug是否等于某些单词(个人资料,专辑等),传递到下一个路线并且不捕获slug和用户名。

any ideas ? 有任何想法吗 ?

You should just put the more specific routes first: 您应该首先放置更具体的路线:

app.post('/:username/profile', middlware)
app.post('/:username/album', middleware)
app.post('/:username/:slug', middleware)

But then again, I don't know what you're trying to accomplish 但话说回来,我不知道你想要完成什么

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM