Skip to content

Commit c929364

Browse files
committed
firefox decode slash
1 parent 4be92cc commit c929364

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/Routing.purs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ foreign import decodeURIComponent :: String -> String
2525
foreign import hashChanged """
2626
function hashChanged(handler) {
2727
return function() {
28-
var currentHash = document.location.hash;
29-
handler("")(currentHash)();
28+
var getHash = function() {return document.location.href.split('#')[1] || '';};
29+
window['__oldHash'] = "";
30+
handler("")(getHash())();
3031
window.addEventListener("hashchange", function(ev) {
31-
handler(ev.oldURL)(ev.newURL)();
32+
var newHash = getHash();
33+
handler(window['__oldHash'])(newHash)();
34+
window['__oldHash'] = newHash;
3235
});
3336
};
3437
}

src/Routing/Hash.purs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import DOM
66
foreign import setHash """
77
function setHash(hash) {
88
return function() {
9-
document.location.hash = hash;
9+
var uri = document.location.href.split('#')[0];
10+
document.location.href = uri + '#' + hash;
1011
};
1112
}
1213
""" :: forall e. String -> Eff (dom :: DOM |e) Unit
1314

1415
foreign import getHash """
1516
function getHash() {
16-
return document.location.hash.replace(/^[^#]*#/g, "");
17+
return document.location.href.split('#')[1] || "";
1718
}
1819
""" :: forall e. Eff (dom :: DOM |e) String
1920

0 commit comments

Comments
 (0)