documentcloud/backbone — pull request #1820 by limnick (2012-11-14 21:42:30+00:00)
Title: routeStripper now properly escapes routes

The comment on line 991 of backbone.js was "cleaning leading hashes and slashes" when the regex clearly only took care of a single hash or a single slash.

I asked on irc and knowtheory helped a bit with the intention of the function, but wasn't able to tell me the original intention of the code.

The comment and matching code were objectively incorrect, and I made some assumptions about what the correct behavior should be.

It boils down to "which of the following routes are valid and identical?"

I decided that
* #route
* /route
* #/route
* /#route
* /#/route

are all identical and that anything else should not be stripped.