Trailing slashes

Before we move on from routes there is one last detail worth mentioning: trailing slashes. Normally web developers don't need to think about trailing slashes, because most web servers treat foo and foo/ the same. Technically however they are different, and Backbone treats them as such, which means that a route of foo will not be triggered when the user navigates to foo/.

Luckily this can easily be solved if you are using routing strings by adding (/) to the end of each string. If you are using regular expressions you can achieve a similar effect by adding /? to the end of each of your regular expressions. However, if you are using simple strings you will either need to define two separate routes (foo and foo/), or you will just need to be careful never to create any links to foo/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.111.49