Skip to content

firefox decode slash #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/Routing.purs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ foreign import decodeURIComponent :: String -> String
foreign import hashChanged """
function hashChanged(handler) {
return function() {
var currentHash = document.location.hash;
handler("")(currentHash)();
var getHash = function() {
return document.location.href.split('#').splice(1).join('#');
};
var oldHash = "";
handler("")(getHash())();
window.addEventListener("hashchange", function(ev) {
handler(ev.oldURL)(ev.newURL)();
var newHash = getHash();
handler(oldHash)(newHash)();
oldHash = newHash;
});
};
}
Expand Down
5 changes: 3 additions & 2 deletions src/Routing/Hash.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import DOM
foreign import setHash """
function setHash(hash) {
return function() {
document.location.hash = hash;
var uri = document.location.href.split('#')[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps use location.href.substring(location.href.indexOf("#") + 1) kind of thing here instead, in case there is a second hash in the hash?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we take uri without hash.

document.location.href = uri + '#' + hash;
};
}
""" :: forall e. String -> Eff (dom :: DOM |e) Unit

foreign import getHash """
function getHash() {
return document.location.hash.replace(/^[^#]*#/g, "");
return document.location.href.split('#').splice(1).join('#');
}
""" :: forall e. Eff (dom :: DOM |e) String

Expand Down