Trailing Slash Optional

I want my paths in Mojito to allow the trailing slash to be optional.

I thought when I was first looking at Mojito there was an option to allow for this but I can't find it now.

I simply want paths like this: "/topic/:topicName/" to match urls like /topic/books and topic/books/

2 Replies
  • You might want to define your route as follows:

    "topic": {
        "path": "/topic/:topicName",
        "regex": {
            "topicName": "[^/]+/?"

    You can adjust the regex to be more specific if you would like, but in general this should give you the behavior you are looking for. Perhaps this is the option you are referring to.

    Btw, we are currently working on the next version of Mojito where this is addressed. You would specify your path as "/topic/:topicName" and that should give you the same behavior.

  • Thanks for the help. I was hoping to avoid using regex but it does work for now.


Recent Posts

in Yahoo! Mojito