You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
. 1 look the following code. I use a regular exp to match a path and route the request to pageRouter.When I request the localhost:8000/new, the regular EXP looks not work, but I have test the EXP use /^/(?!api$|api/.|resource$|resource/.)/.test('/new'), it return true. and if I use /(?!api$|api/.|resource$|resource/.)/ it works but that against with the api doc.
router.use('/api',apiRouter);
router.use('/resource',resourceRouter);
router.use(/^\/(?!api$|api\/.*|resource$|resource\/.*)/,pageRouter);
pageRouter.get("*",(req,resp,next)=>{let name = req.originalUrl...})
. 2 look the following code. The request first through the resourceRouter then through pageRouter but I think that should be just through the resourceRouter .
router.use('/api',apiRouter);
router.use('/resource',resourceRouter);
router.use("/",pageRouter);
pageRouter.get("*",(req,resp,next)=>{let name = req.originalUrl...})
The text was updated successfully, but these errors were encountered:
HI @sinbargit the issue with your regular expression is how .use works. It is not just a matter of does the regular expression match the input, but since .use needs to strip down the matched path, it expects your match to stop before a / character to cut on.
The regular expression on your URL is matching one character, which makes the cut-off point the character t, which is not a / character. If you want to continue down the regular expression path, the easiest solution is to just adjust the regular expression to match just the part you want to cut off prior to entering the pageRouter. If you want to cut nothing (i.e. enter the pageRouter with the full URL), then use /^(?!\/api$|\/api\/.|\/resource$|\/resource\/.)/.
Express version:4.15.4 ,nodeJs version:6.11
. 1 look the following code. I use a regular exp to match a path and route the request to pageRouter.When I request the localhost:8000/new, the regular EXP looks not work, but I have test the EXP use /^/(?!api$|api/.|resource$|resource/.)/.test('/new'), it return true. and if I use /(?!api$|api/.|resource$|resource/.)/ it works but that against with the api doc.
. 2 look the following code. The request first through the
resourceRouter
then throughpageRouter
but I think that should be just through theresourceRouter
.The text was updated successfully, but these errors were encountered: