javascriptsammy.js

Catch-all or error routes in Sammy.js


Is it possible to define a catch-all route or an error route in Sammy.js? I know I can bind to 'error' but if no route matches that does not seem to be triggered.

Thanks!


Solution

  • According to the documentation for Sammy routes,

    Paths can be defined as strings or regular expressions.

    As such, it should be possible to create a route like this, at the end of your routes, that is a catch-all:

    get(/.*/, function() { 
      ...
    });