Skip to content

Commit

Permalink
fixed issue #46 and #50
Browse files Browse the repository at this point in the history
  • Loading branch information
devote committed Mar 24, 2014
1 parent eda868e commit 75d248b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 49 deletions.
2 changes: 1 addition & 1 deletion bower.json
Expand Up @@ -2,7 +2,7 @@
"name": "history",
"repo": "devote/HTML5-History-API",
"description": "HTML5 History API expansion for browsers not supporting pushState, replaceState",
"version": "4.0.9",
"version": "4.1.0",
"keywords": ["history", "pushState", "replaceState"],
"main": "history.js",
"scripts": ["history.js"],
Expand Down
17 changes: 10 additions & 7 deletions history.iegte8.js
@@ -1,5 +1,5 @@
/*!
* History API JavaScript Library v4.0.9
* History API JavaScript Library v4.1.0
*
* Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other
*
Expand All @@ -11,7 +11,7 @@
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Update: 2013-11-20 13:03
* Update: 2014-03-24 13:14
*/
(function(window) {
// Prevent the code from running if there is no window.history object
Expand Down Expand Up @@ -362,7 +362,8 @@
// get hash fragment
href = href.replace(/^[^#]*/, '') || "#";
// form the absolute link from the hash
href = windowLocation.protocol + '//' + windowLocation.host + settings['basepath']
// https://github.com/devote/HTML5-History-API/issues/50
href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath']
+ href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), "");
}
}
Expand Down Expand Up @@ -728,8 +729,12 @@
* @return void
*/
function onHashChange(event) {
// if not empty lastURL, otherwise skipped the current handler event
if (lastURL) {
// https://github.com/devote/HTML5-History-API/issues/46
var fireNow = lastURL;
// new value to lastURL
lastURL = windowLocation.href;
// if not empty fireNow, otherwise skipped the current handler event
if (fireNow) {
// if checkUrlForPopState equal current url, this means that the event was raised popstate browser
if (checkUrlForPopState !== windowLocation.href) {
// otherwise,
Expand All @@ -751,8 +756,6 @@
dispatchEvent(event);
}
}
// new value to lastURL
lastURL = windowLocation.href;
}

/**
Expand Down
26 changes: 13 additions & 13 deletions history.iegte8.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions history.js
@@ -1,5 +1,5 @@
/*!
* History API JavaScript Library v4.0.9
* History API JavaScript Library v4.1.0
*
* Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other
*
Expand All @@ -11,7 +11,7 @@
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Update: 2013-11-20 13:03
* Update: 2014-03-24 13:14
*/
(function(window) {
// Prevent the code from running if there is no window.history object
Expand Down Expand Up @@ -362,7 +362,8 @@
// get hash fragment
href = href.replace(/^[^#]*/, '') || "#";
// form the absolute link from the hash
href = windowLocation.protocol + '//' + windowLocation.host + settings['basepath']
// https://github.com/devote/HTML5-History-API/issues/50
href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath']
+ href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), "");
}
}
Expand Down Expand Up @@ -728,8 +729,12 @@
* @return void
*/
function onHashChange(event) {
// if not empty lastURL, otherwise skipped the current handler event
if (lastURL) {
// https://github.com/devote/HTML5-History-API/issues/46
var fireNow = lastURL;
// new value to lastURL
lastURL = windowLocation.href;
// if not empty fireNow, otherwise skipped the current handler event
if (fireNow) {
// if checkUrlForPopState equal current url, this means that the event was raised popstate browser
if (checkUrlForPopState !== windowLocation.href) {
// otherwise,
Expand All @@ -751,8 +756,6 @@
dispatchEvent(event);
}
}
// new value to lastURL
lastURL = windowLocation.href;
}

/**
Expand Down

0 comments on commit 75d248b

Please sign in to comment.