Backbone.js and regex routing

Is it possible to register a route for /pages/*url, but not for /pages/*url/edit/, where the URL might look something like this foo/bar/and-so-on:?

+3
source share
1 answer

router.route supports regex.

initialize: function(options) {

  // Matches /117-a/b/c/open, passing "117-a/b/c" to this.open
  this.route(/^(.*?)\/open$/, "open");

},

open: function(id) { ... }
+4
source

All Articles