Multiple optional route parameters in Express?

The expressjs’s guide to routing mentions:

Express uses path-to-regexp for matching the route paths; see the
path-to-regexp documentation for all the possibilities in defining
route paths. Express Route Tester is a handy tool for testing basic
Express routes, although it does not support pattern matching.

Basically, you can use the ? character to make the parameter optional.

/articles/:year?/:month?/:day?

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)