documentcloud/backbone — pull request #967 by jacob-harding (2012-02-07 05:49:16+00:00)
Title: Get the hash value from location.href rather than location.hash

The method `getFragment` currently decodes the fragment before returning it. Due to a [bug in Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=483304) where `location.hash` is decoded, I assume the reason why the fragment gets decoded is to normalize across browsers. However this can cause issues when attempting to navigate to a URL that has some encoded characters. For example if my router contained this:

```javascript
routes = {
'*path': 'goTo'
},

goTo: function(path) {
...
}
```

If `router.navigate('has%20space', { trigger: true });` was called, I'd expect `path` to have the value `'has%20space'` but instead it has the value `'has space'`.

In the changes I made, the hash value is retrieved from `location.href` rather than `location.hash` as a workaround to the Firefox bug. I created a helper method `getHash` that will split `location.href` at the '#' character and returns what comes after it. This allowed me to remove the code that decoded the fragment in `getFragment` since it is no longer necessary.