history-manager
Advanced tools
Comparing version 2.0.0 to 2.1.0
{ | ||
"name": "history-manager", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -26,2 +26,8 @@ /** | ||
window.addEventListener("popstate", listener, true); | ||
// remove options of just loaded page | ||
if (Object.keys(get()).length > 0) { | ||
set({}); | ||
} | ||
return destroyEventListener = () => { | ||
@@ -148,7 +154,2 @@ window.removeEventListener("popstate", listener, true); | ||
return splitHref()[0]; | ||
} | ||
// remove options of just loaded page | ||
if (Object.keys(get()).length > 0) { | ||
set({}); | ||
} |
@@ -9,13 +9,26 @@ /** | ||
let BASE: string = "#"; | ||
const LOCATION_BASE: string = `${ | ||
window.location.protocol | ||
}//${ | ||
window.location.host | ||
}`; | ||
const LOCATION_PATHNAME = window.location.pathname; | ||
let LOCATION_BASE: string | null = null; | ||
let LOCATION_PATHNAME: string | null = null; | ||
function getLocation() { | ||
return LOCATION_BASE + (BASE[0] === "#" ? LOCATION_PATHNAME : ""); | ||
function getLocationBase() { | ||
if (LOCATION_BASE !== null) { | ||
return LOCATION_BASE; | ||
} | ||
return LOCATION_BASE = `${ | ||
window.location.protocol | ||
}//${ | ||
window.location.host | ||
}`; | ||
} | ||
function getLocationPathname() { | ||
if (LOCATION_PATHNAME !== null) { | ||
return LOCATION_PATHNAME; | ||
} | ||
return LOCATION_PATHNAME = window.location.pathname; | ||
} | ||
function getLocation(): string { | ||
return getLocationBase() + (BASE[0] === "#" ? getLocationPathname() : ""); | ||
} | ||
const parenthesesRegex: RegExp = /[\\\/]+/g; | ||
@@ -22,0 +35,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
243118
7073