Skip to content

Commit

Permalink
Fix for IE6 bug involving question mark in hash.
Browse files Browse the repository at this point in the history
If a question mark appears in a URL fragment, IE6 will exclude the
question mark and everything after it from `window.location.hash`.  For
example, given the location:

    http://example.com/#/docs?page=1&per_page=10

The value of `window.location.hash` will be:

    #/docs

By bypassing `window.location.hash` and parsing the URL within Sammy to
extract the fragment we can avoid cross-browser inconsistencies like
this one.
  • Loading branch information
hallettj committed Aug 30, 2009
1 parent b21f005 commit 7e900af
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/sammy.js
Expand Up @@ -606,7 +606,15 @@
// Override this and <tt>setLocation()</tt> to detach the app from the
// window.location object.
getLocation: function() {
return this.clone(window.location).hash.toString();
// Bypass the `window.location.hash` attribute. If a question mark
// appears in the hash IE6 will strip it and all of the following
// characters from `window.location.hash`.
var matches = window.location.toString().match(/^[^#]*(#.+)$/);
if (matches) {
return matches[1];
} else {
return '';
}
},

// The default behavior is to set the current window's location.
Expand Down

0 comments on commit 7e900af

Please sign in to comment.