Skip to content

Commit 75d248b

Browse files
committed
fixed issue #46 and #50
1 parent eda868e commit 75d248b

6 files changed

Lines changed: 55 additions & 49 deletions

File tree

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "history",
33
"repo": "devote/HTML5-History-API",
44
"description": "HTML5 History API expansion for browsers not supporting pushState, replaceState",
5-
"version": "4.0.9",
5+
"version": "4.1.0",
66
"keywords": ["history", "pushState", "replaceState"],
77
"main": "history.js",
88
"scripts": ["history.js"],

history.iegte8.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* History API JavaScript Library v4.0.9
2+
* History API JavaScript Library v4.1.0
33
*
44
* Support: IE8+, FF3+, Opera 9+, Safari, Chrome and other
55
*
@@ -11,7 +11,7 @@
1111
* http://www.opensource.org/licenses/mit-license.php
1212
* http://www.gnu.org/licenses/gpl.html
1313
*
14-
* Update: 2013-11-20 13:03
14+
* Update: 2014-03-24 13:14
1515
*/
1616
(function(window) {
1717
// Prevent the code from running if there is no window.history object
@@ -362,7 +362,8 @@
362362
// get hash fragment
363363
href = href.replace(/^[^#]*/, '') || "#";
364364
// form the absolute link from the hash
365-
href = windowLocation.protocol + '//' + windowLocation.host + settings['basepath']
365+
// https://github.com/devote/HTML5-History-API/issues/50
366+
href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath']
366367
+ href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), "");
367368
}
368369
}
@@ -728,8 +729,12 @@
728729
* @return void
729730
*/
730731
function onHashChange(event) {
731-
// if not empty lastURL, otherwise skipped the current handler event
732-
if (lastURL) {
732+
// https://github.com/devote/HTML5-History-API/issues/46
733+
var fireNow = lastURL;
734+
// new value to lastURL
735+
lastURL = windowLocation.href;
736+
// if not empty fireNow, otherwise skipped the current handler event
737+
if (fireNow) {
733738
// if checkUrlForPopState equal current url, this means that the event was raised popstate browser
734739
if (checkUrlForPopState !== windowLocation.href) {
735740
// otherwise,
@@ -751,8 +756,6 @@
751756
dispatchEvent(event);
752757
}
753758
}
754-
// new value to lastURL
755-
lastURL = windowLocation.href;
756759
}
757760

758761
/**

history.iegte8.min.js

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

history.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* History API JavaScript Library v4.0.9
2+
* History API JavaScript Library v4.1.0
33
*
44
* Support: IE6+, FF3+, Opera 9+, Safari, Chrome and other
55
*
@@ -11,7 +11,7 @@
1111
* http://www.opensource.org/licenses/mit-license.php
1212
* http://www.gnu.org/licenses/gpl.html
1313
*
14-
* Update: 2013-11-20 13:03
14+
* Update: 2014-03-24 13:14
1515
*/
1616
(function(window) {
1717
// Prevent the code from running if there is no window.history object
@@ -362,7 +362,8 @@
362362
// get hash fragment
363363
href = href.replace(/^[^#]*/, '') || "#";
364364
// form the absolute link from the hash
365-
href = windowLocation.protocol + '//' + windowLocation.host + settings['basepath']
365+
// https://github.com/devote/HTML5-History-API/issues/50
366+
href = windowLocation.protocol.replace(/:.*$|$/, ':') + '//' + windowLocation.host + settings['basepath']
366367
+ href.replace(new RegExp("^#[\/]?(?:" + settings["type"] + ")?"), "");
367368
}
368369
}
@@ -728,8 +729,12 @@
728729
* @return void
729730
*/
730731
function onHashChange(event) {
731-
// if not empty lastURL, otherwise skipped the current handler event
732-
if (lastURL) {
732+
// https://github.com/devote/HTML5-History-API/issues/46
733+
var fireNow = lastURL;
734+
// new value to lastURL
735+
lastURL = windowLocation.href;
736+
// if not empty fireNow, otherwise skipped the current handler event
737+
if (fireNow) {
733738
// if checkUrlForPopState equal current url, this means that the event was raised popstate browser
734739
if (checkUrlForPopState !== windowLocation.href) {
735740
// otherwise,
@@ -751,8 +756,6 @@
751756
dispatchEvent(event);
752757
}
753758
}
754-
// new value to lastURL
755-
lastURL = windowLocation.href;
756759
}
757760

758761
/**

0 commit comments

Comments
 (0)