mixdown-router
Advanced tools
Comparing version 2.0.7 to 3.0.0
12
index.js
@@ -30,3 +30,3 @@ var _ = require('lodash'); | ||
// Cached regex for stripping a leading hash/slash and trailing space. | ||
var routeStripper = /^[#\/]|\s+$/g; | ||
var routeStripper = /^[#\/]+|\s+$/g; | ||
@@ -127,5 +127,9 @@ // Cached regex for stripping leading and trailing slashes. | ||
// Build a URL string for navigating w/o hash or additional search params | ||
var getUrlString = function() { | ||
var loc = window.location; | ||
return loc.protocol + '//' + loc.host + self.root + ((loc.hash) ? loc.hash.replace(routeStripper, '') : loc.search); | ||
}; | ||
if (self._hasPushState) { | ||
// The popstate event - A popstate event is dispatched to the window every time the active history | ||
@@ -142,3 +146,3 @@ // entry changes. If the history entry being activated was created by a call to pushState or affected | ||
window.onpopstate = function(e) { | ||
self.navigate(window.location.href); | ||
self.navigate(getUrlString()); | ||
}; | ||
@@ -148,3 +152,3 @@ | ||
self.navigate(window.location.href, callback); | ||
self.navigate(getUrlString(), callback); | ||
}; | ||
@@ -151,0 +155,0 @@ |
{ | ||
"name": "mixdown-router", | ||
"version": "2.0.7", | ||
"version": "3.0.0", | ||
"description": "Router for mixdown.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
33994
647