Skip to content

Commit

Permalink
simplify hasher.raw logic. see #59
Browse files Browse the repository at this point in the history
  • Loading branch information
millermedeiros committed Nov 11, 2013
1 parent 71ed239 commit 5da397a
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions dev/src/hasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ var hasher = (function(window){
//parsed full URL instead of getting window.location.hash because Firefox decode hash value (and all the other browsers don't)
//also because of IE8 bug with hash query in local file [issue #6]
var result = _hashValRegexp.exec( hasher.getURL() );
if (hasher.raw) {
return (result && result[1])? result[1] : '';
} else {
return (result && result[1])? decodeURIComponent(result[1]) : '';
}
var path = (result && result[1]) || '';
return hasher.raw? path : decodeURIComponent(path);
}

function _getFrameHash(){
Expand Down Expand Up @@ -338,12 +335,10 @@ var hasher = (function(window){
if (path === _hash) {
// we check if path is still === _hash to avoid error in
// case of multiple consecutive redirects [issue #39]
if (hasher.raw) {
window.location.hash = '#' + path;
} else {
window.location.hash = '#' + _encodePath(path);
if (! hasher.raw) {
path = _encodePath(path);
}

window.location.hash = '#' + path;
}
}
},
Expand All @@ -364,11 +359,10 @@ var hasher = (function(window){
if (path === _hash) {
// we check if path is still === _hash to avoid error in
// case of multiple consecutive redirects [issue #39]
if (hasher.raw) {
window.location.replace('#' + path);
} else {
window.location.replace('#' + _encodePath(path));
if (! hasher.raw) {
path = _encodePath(path);
}
window.location.replace('#' + path);
}
}
},
Expand Down

0 comments on commit 5da397a

Please sign in to comment.