lundi 29 mai 2017

generic pattern: express.js

I would like to create a generic pattern for my routes (using express 4):

router.get('co/:c/works', worksController.list);
router.get('co/:c/bi/:b/works', worksController.list);
router.get('co/:c/bi/:b/pl/:p/works', worksController.list);
router.get('co/:c/pl/:p/works', worksController.list);
router.get('co/:c/pl/:p/bi/:b/works', worksController.list);
...

where :c, :b, :p are identifiers (integer)

Then I am trying to use:

router.get('co/:c\/bi/:b|\/pl/:p+/works', worksController.list);

my problem is that for the route

http://localhost:3000/co/:12/bi/:34/works

the identifiers are truncated after the first character like this:

http://localhost:3000/co/:1/bi/:3/works

could you please help me and tell me how to fix it ?

thank you.

Olivier

Aucun commentaire:

Enregistrer un commentaire