Skip to content

Commit 1dbe3dd

Browse files
committed
Merge pull request #3152 from braddunbar/ie6
Handle incorrect hash/search values in IE6.
2 parents 6a82b0c + 5573ef7 commit 1dbe3dd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

backbone.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,14 @@
14151415
// Are we at the app root?
14161416
atRoot: function() {
14171417
var path = this.location.pathname.replace(/[^\/]$/, '$&/');
1418-
return path === this.root && !this.location.search;
1418+
return path === this.root && !this.getSearch();
1419+
},
1420+
1421+
// In IE6, the hash fragment and search params are incorrect if the
1422+
// fragment contains `?`.
1423+
getSearch: function() {
1424+
var match = this.location.href.replace(/#.*/, '').match(/\?.+/);
1425+
return match ? match[0] : '';
14191426
},
14201427

14211428
// Gets the true hash value. Cannot use location.hash directly due to bug
@@ -1427,7 +1434,7 @@
14271434

14281435
// Get the pathname and search params, without the root.
14291436
getPath: function() {
1430-
var path = decodeURI(this.location.pathname + this.location.search);
1437+
var path = decodeURI(this.location.pathname + this.getSearch());
14311438
var root = this.root.slice(0, -1);
14321439
if (!path.indexOf(root)) path = path.slice(root.length);
14331440
return path.slice(1);

0 commit comments

Comments
 (0)