Skip to content

Commit 1e7cf56

Browse files
committed
Merge pull request #11 from cryogenian/squashed
firefox decode slash
2 parents 4be92cc + 95e38dc commit 1e7cf56

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Routing.purs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ 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() {
29+
return document.location.href.split('#').splice(1).join('#');
30+
};
31+
var oldHash = "";
32+
handler("")(getHash())();
3033
window.addEventListener("hashchange", function(ev) {
31-
handler(ev.oldURL)(ev.newURL)();
34+
var newHash = getHash();
35+
handler(oldHash)(newHash)();
36+
oldHash = newHash;
3237
});
3338
};
3439
}

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('#').splice(1).join('#');
1718
}
1819
""" :: forall e. Eff (dom :: DOM |e) String
1920

0 commit comments

Comments
 (0)