Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@recore/history

Package Overview
Dependencies
Maintainers
7
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@recore/history - npm Package Compare versions

Comparing version 4.10.2 to 4.11.0

4

cjs/history.js

@@ -383,3 +383,3 @@ 'use strict';

domPathname = window.location.pathname || '/';
var pathname = pathInQuery ? parseQuery(search)[pathInQuery] || '/' : domPathname;
var pathname = pathInQuery ? addLeadingSlash(parseQuery(search)[pathInQuery] || '') : domPathname;
var path = pathname + search + hash;

@@ -458,3 +458,3 @@ warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".');

var query = parseQuery(location.search);
query[pathInQuery] = basename + location.pathname;
query[pathInQuery] = stripTrailingSlash(stripLeadingSlash(basename + location.pathname));
return createPath(_extends({}, location, {

@@ -461,0 +461,0 @@ pathname: domPathname,

@@ -1,1 +0,1 @@

"use strict";function _interopDefault(n){return n&&"object"==typeof n&&"default"in n?n.default:n}Object.defineProperty(exports,"__esModule",{value:!0});var resolvePathname=_interopDefault(require("resolve-pathname")),valueEqual=_interopDefault(require("value-equal"));require("tiny-warning");var invariant=_interopDefault(require("tiny-invariant"));function _extends(){return(_extends=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n}).apply(this,arguments)}function addLeadingSlash(n){return"/"===n.charAt(0)?n:"/"+n}function stripLeadingSlash(n){return"/"===n.charAt(0)?n.substr(1):n}function hasBasename(n,t){return 0===n.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(n.charAt(t.length))}function stripBasename(n,t){return hasBasename(n,t)?n.substr(t.length):n}function stripTrailingSlash(n){return"/"===n.charAt(n.length-1)?n.slice(0,-1):n}function parsePath(n){var t=n||"/",e="",a="",r=t.indexOf("#");-1!==r&&(a=t.substr(r),t=t.substr(0,r));var i=t.indexOf("?");return-1!==i&&(e=t.substr(i),t=t.substr(0,i)),{pathname:t,search:"?"===e?"":e,hash:"#"===a?"":a}}function createPath(n){var t=n.pathname,e=n.search,a=n.hash,r=t||"/";return e&&"?"!==e&&(r+="?"===e.charAt(0)?e:"?"+e),a&&"#"!==a&&(r+="#"===a.charAt(0)?a:"#"+a),r}function decode(n){return n&&(n=n.replace(/\+/g,"%20"),n=decodeURIComponent(n)),n}function parseQuery(n){var t={};if(!n)return t;0===n.indexOf("?")&&(n=n.substring(1));for(var e,a,r,i,o=n.split(/[&;]/),s=0,c=o.length;s<c;s++)0!==(a=(e=o[s]).indexOf("="))&&(i=a<0?(r=e,null):(r=decode(e.substring(0,a)),decode(e.substring(a+1))),r in t?(Array.isArray(t[r])||(t[r]=[t[r]]),t[r].push(i)):t[r]=i);return t}function stringifyPrimitive(n){switch(typeof n){case"string":return n;case"boolean":return n?"true":"false";case"number":return isFinite(n)?n:"";default:return""}}function formatQuery(e){return Object.keys(e).map(function(n){var t=encodeURIComponent(stringifyPrimitive(n))+"=";return Array.isArray(e[n])?e[n].map(function(n){return t+encodeURIComponent(stringifyPrimitive(n))}).join("&"):t+encodeURIComponent(stringifyPrimitive(e[n]))}).filter(Boolean).join("&")}function createLocation(n,t,e,a){var r;"string"==typeof n?(r=parsePath(n)).state=t:(void 0===(r=_extends({},n)).pathname&&(r.pathname=""),r.search?"?"!==r.search.charAt(0)&&(r.search="?"+r.search):r.search="",r.hash?"#"!==r.hash.charAt(0)&&(r.hash="#"+r.hash):r.hash="",void 0!==t&&void 0===r.state&&(r.state=t));try{r.pathname=decodeURI(r.pathname)}catch(n){throw n instanceof URIError?new URIError('Pathname "'+r.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):n}return e&&(r.key=e),a?r.pathname?"/"!==r.pathname.charAt(0)&&(r.pathname=resolvePathname(r.pathname,a.pathname)):r.pathname=a.pathname:r.pathname||(r.pathname="/"),r}function locationsAreEqual(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash&&n.key===t.key&&valueEqual(n.state,t.state)}function createTransitionManager(){var i=null;var a=[];return{setPrompt:function(n){return i=n,function(){i===n&&(i=null)}},confirmTransitionTo:function(n,t,e,a){if(null!=i){var r="function"==typeof i?i(n,t):i;"string"==typeof r?"function"==typeof e?e(r,a):a(!0):a(!1!==r)}else a(!0)},appendListener:function(n){var t=!0;function e(){t&&n.apply(void 0,arguments)}return a.push(e),function(){t=!1,a=a.filter(function(n){return n!==e})}},notifyListeners:function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];a.forEach(function(n){return n.apply(void 0,t)})}}}var canUseDOM=!("undefined"==typeof window||!window.document||!window.document.createElement);function getConfirmation(n,t){t(window.confirm(n))}function supportsHistory(){var n=window.navigator.userAgent;return(-1===n.indexOf("Android 2.")&&-1===n.indexOf("Android 4.0")||-1===n.indexOf("Mobile Safari")||-1!==n.indexOf("Chrome")||-1!==n.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}function supportsPopStateOnHashChange(){return-1===window.navigator.userAgent.indexOf("Trident")}function supportsGoWithoutReloadUsingHash(){return-1===window.navigator.userAgent.indexOf("Firefox")}function isExtraneousPopstateEvent(n){return void 0===n.state&&-1===navigator.userAgent.indexOf("CriOS")}var PopStateEvent="popstate",HashChangeEvent="hashchange";function getHistoryState(){try{return window.history.state||{}}catch(n){return{}}}function createBrowserHistory(n){void 0===n&&(n={}),canUseDOM||invariant(!1);var s=window.history,c=supportsHistory(),t=!supportsPopStateOnHashChange(),e=n,a=e.forceRefresh,h=void 0!==a&&a,u=e.pathInQuery,r=e.getUserConfirmation,f=void 0===r?getConfirmation:r,i=e.keyLength,o=void 0===i?6:i,d=n.basename?stripTrailingSlash(addLeadingSlash(n.basename)):"",l="/";function p(n){var t=n||{},e=t.key,a=t.state,r=window.location,i=r.search,o=r.hash;l=window.location.pathname||"/";var s=(u?parseQuery(i)[u]||"/":l)+i+o;return d&&(s=stripBasename(s,d)),createLocation(s,a,e)}function v(){return Math.random().toString(36).substr(2,o)}var g=createTransitionManager();function m(n){_extends(A,n),A.length=s.length,g.notifyListeners(A.location,A.action)}function P(n){isExtraneousPopstateEvent(n)||H(p(n.state))}function y(){H(p(getHistoryState()))}var w=!1;function H(t){if(w)w=!1,m();else{g.confirmTransitionTo(t,"POP",f,function(n){n?m({action:"POP",location:t}):function(n){var t=A.location,e=O.indexOf(t.key);-1===e&&(e=0);var a=O.indexOf(n.key);-1===a&&(a=0);var r=e-a;r&&(w=!0,E(r))}(t)})}}var x=p(getHistoryState()),O=[x.key];function L(n){if(u){var t=parseQuery(n.search);return t[u]=d+n.pathname,createPath(_extends({},n,{pathname:l,search:"?"+formatQuery(t)}))}return d+createPath(n)}function E(n){s.go(n)}var S=0;function b(n){1===(S+=n)&&1===n?(window.addEventListener(PopStateEvent,P),t&&window.addEventListener(HashChangeEvent,y)):0===S&&(window.removeEventListener(PopStateEvent,P),t&&window.removeEventListener(HashChangeEvent,y))}var T=!1;var A={length:s.length,action:"POP",location:x,createHref:L,push:function(n,t){var o=createLocation(n,t,v(),A.location);g.confirmTransitionTo(o,"PUSH",f,function(n){if(n){var t=L(o),e=o.key,a=o.state;if(c)if(s.pushState({key:e,state:a},null,t),h)window.location.href=t;else{var r=O.indexOf(A.location.key),i=O.slice(0,r+1);i.push(o.key),O=i,m({action:"PUSH",location:o})}else window.location.href=t}})},replace:function(n,t){var i="REPLACE",o=createLocation(n,t,v(),A.location);g.confirmTransitionTo(o,i,f,function(n){if(n){var t=L(o),e=o.key,a=o.state;if(c)if(s.replaceState({key:e,state:a},null,t),h)window.location.replace(t);else{var r=O.indexOf(A.location.key);-1!==r&&(O[r]=o.key),m({action:i,location:o})}else window.location.replace(t)}})},go:E,goBack:function(){E(-1)},goForward:function(){E(1)},block:function(n){void 0===n&&(n=!1);var t=g.setPrompt(n);return T||(b(1),T=!0),function(){return T&&(T=!1,b(-1)),t()}},listen:function(n){var t=g.appendListener(n);return b(1),function(){b(-1),t()}}};return A}var HashChangeEvent$1="hashchange",HashPathCoders={hashbang:{encodePath:function(n){return"!"===n.charAt(0)?n:"!/"+stripLeadingSlash(n)},decodePath:function(n){return"!"===n.charAt(0)?n.substr(1):n}},noslash:{encodePath:stripLeadingSlash,decodePath:addLeadingSlash},slash:{encodePath:addLeadingSlash,decodePath:addLeadingSlash}};function stripHash(n){var t=n.indexOf("#");return-1===t?n:n.slice(0,t)}function getHashPath(){var n=window.location.href,t=n.indexOf("#");return-1===t?"":n.substring(t+1)}function pushHashPath(n){window.location.hash=n}function replaceHashPath(n){window.location.replace(stripHash(window.location.href)+"#"+n)}function createHashHistory(n){void 0===n&&(n={}),canUseDOM||invariant(!1);var t=window.history,e=(supportsGoWithoutReloadUsingHash(),n),a=e.getUserConfirmation,o=void 0===a?getConfirmation:a,r=e.hashType,i=void 0===r?"slash":r,s=n.basename?stripTrailingSlash(addLeadingSlash(n.basename)):"",c=HashPathCoders[i],h=c.encodePath,u=c.decodePath;function f(){var n=u(getHashPath());return s&&(n=stripBasename(n,s)),createLocation(n)}var d=createTransitionManager();function l(n){_extends(E,n),E.length=t.length,d.notifyListeners(E.location,E.action)}var p=!1,v=null;function g(){var n=getHashPath(),t=h(n);if(n!==t)replaceHashPath(t);else{var e=f(),a=E.location;if(!p&&function(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash}(a,e))return;if(v===createPath(e))return;v=null,function(t){if(p)p=!1,l();else{d.confirmTransitionTo(t,"POP",o,function(n){n?l({action:"POP",location:t}):function(n){var t=E.location,e=w.lastIndexOf(createPath(t));-1===e&&(e=0);var a=w.lastIndexOf(createPath(n));-1===a&&(a=0);var r=e-a;r&&(p=!0,H(r))}(t)})}}(e)}}var m=getHashPath(),P=h(m);m!==P&&replaceHashPath(P);var y=f(),w=[createPath(y)];function H(n){t.go(n)}var x=0;function O(n){1===(x+=n)&&1===n?window.addEventListener(HashChangeEvent$1,g):0===x&&window.removeEventListener(HashChangeEvent$1,g)}var L=!1;var E={length:t.length,action:"POP",location:y,createHref:function(n){var t=document.querySelector("base"),e="";return t&&t.getAttribute("href")&&(e=stripHash(window.location.href)),e+"#"+h(s+createPath(n))},push:function(n,t){var i=createLocation(n,void 0,void 0,E.location);d.confirmTransitionTo(i,"PUSH",o,function(n){if(n){var t=createPath(i),e=h(s+t);if(getHashPath()!==e){v=t,pushHashPath(e);var a=w.lastIndexOf(createPath(E.location)),r=w.slice(0,a+1);r.push(t),w=r,l({action:"PUSH",location:i})}else l()}})},replace:function(n,t){var r="REPLACE",i=createLocation(n,void 0,void 0,E.location);d.confirmTransitionTo(i,r,o,function(n){if(n){var t=createPath(i),e=h(s+t);getHashPath()!==e&&(v=t,replaceHashPath(e));var a=w.indexOf(createPath(E.location));-1!==a&&(w[a]=t),l({action:r,location:i})}})},go:H,goBack:function(){H(-1)},goForward:function(){H(1)},block:function(n){void 0===n&&(n=!1);var t=d.setPrompt(n);return L||(O(1),L=!0),function(){return L&&(L=!1,O(-1)),t()}},listen:function(n){var t=d.appendListener(n);return O(1),function(){O(-1),t()}}};return E}function clamp(n,t,e){return Math.min(Math.max(n,t),e)}function createMemoryHistory(n){void 0===n&&(n={});var t=n,r=t.getUserConfirmation,e=t.initialEntries,a=void 0===e?["/"]:e,i=t.initialIndex,o=void 0===i?0:i,s=t.keyLength,c=void 0===s?6:s,h=createTransitionManager();function u(n){_extends(g,n),g.length=g.entries.length,h.notifyListeners(g.location,g.action)}function f(){return Math.random().toString(36).substr(2,c)}var d=clamp(o,0,a.length-1),l=a.map(function(n){return createLocation(n,void 0,"string"==typeof n?f():n.key||f())}),p=createPath;function v(n){var t=clamp(g.index+n,0,g.entries.length-1),e=g.entries[t];h.confirmTransitionTo(e,"POP",r,function(n){n?u({action:"POP",location:e,index:t}):u()})}var g={length:l.length,action:"POP",location:l[d],index:d,entries:l,createHref:p,push:function(n,t){var a=createLocation(n,t,f(),g.location);h.confirmTransitionTo(a,"PUSH",r,function(n){if(n){var t=g.index+1,e=g.entries.slice(0);e.length>t?e.splice(t,e.length-t,a):e.push(a),u({action:"PUSH",location:a,index:t,entries:e})}})},replace:function(n,t){var e="REPLACE",a=createLocation(n,t,f(),g.location);h.confirmTransitionTo(a,e,r,function(n){n&&(g.entries[g.index]=a,u({action:e,location:a}))})},go:v,goBack:function(){v(-1)},goForward:function(){v(1)},canGo:function(n){var t=g.index+n;return 0<=t&&t<g.entries.length},block:function(n){return void 0===n&&(n=!1),h.setPrompt(n)},listen:function(n){return h.appendListener(n)}};return g}exports.createBrowserHistory=createBrowserHistory,exports.createHashHistory=createHashHistory,exports.createMemoryHistory=createMemoryHistory,exports.createLocation=createLocation,exports.locationsAreEqual=locationsAreEqual,exports.parsePath=parsePath,exports.createPath=createPath;
"use strict";function _interopDefault(n){return n&&"object"==typeof n&&"default"in n?n.default:n}Object.defineProperty(exports,"__esModule",{value:!0});var resolvePathname=_interopDefault(require("resolve-pathname")),valueEqual=_interopDefault(require("value-equal"));require("tiny-warning");var invariant=_interopDefault(require("tiny-invariant"));function _extends(){return(_extends=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n}).apply(this,arguments)}function addLeadingSlash(n){return"/"===n.charAt(0)?n:"/"+n}function stripLeadingSlash(n){return"/"===n.charAt(0)?n.substr(1):n}function hasBasename(n,t){return 0===n.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(n.charAt(t.length))}function stripBasename(n,t){return hasBasename(n,t)?n.substr(t.length):n}function stripTrailingSlash(n){return"/"===n.charAt(n.length-1)?n.slice(0,-1):n}function parsePath(n){var t=n||"/",e="",a="",r=t.indexOf("#");-1!==r&&(a=t.substr(r),t=t.substr(0,r));var i=t.indexOf("?");return-1!==i&&(e=t.substr(i),t=t.substr(0,i)),{pathname:t,search:"?"===e?"":e,hash:"#"===a?"":a}}function createPath(n){var t=n.pathname,e=n.search,a=n.hash,r=t||"/";return e&&"?"!==e&&(r+="?"===e.charAt(0)?e:"?"+e),a&&"#"!==a&&(r+="#"===a.charAt(0)?a:"#"+a),r}function decode(n){return n&&(n=n.replace(/\+/g,"%20"),n=decodeURIComponent(n)),n}function parseQuery(n){var t={};if(!n)return t;0===n.indexOf("?")&&(n=n.substring(1));for(var e,a,r,i,o=n.split(/[&;]/),s=0,c=o.length;s<c;s++)0!==(a=(e=o[s]).indexOf("="))&&(i=a<0?(r=e,null):(r=decode(e.substring(0,a)),decode(e.substring(a+1))),r in t?(Array.isArray(t[r])||(t[r]=[t[r]]),t[r].push(i)):t[r]=i);return t}function stringifyPrimitive(n){switch(typeof n){case"string":return n;case"boolean":return n?"true":"false";case"number":return isFinite(n)?n:"";default:return""}}function formatQuery(e){return Object.keys(e).map(function(n){var t=encodeURIComponent(stringifyPrimitive(n))+"=";return Array.isArray(e[n])?e[n].map(function(n){return t+encodeURIComponent(stringifyPrimitive(n))}).join("&"):t+encodeURIComponent(stringifyPrimitive(e[n]))}).filter(Boolean).join("&")}function createLocation(n,t,e,a){var r;"string"==typeof n?(r=parsePath(n)).state=t:(void 0===(r=_extends({},n)).pathname&&(r.pathname=""),r.search?"?"!==r.search.charAt(0)&&(r.search="?"+r.search):r.search="",r.hash?"#"!==r.hash.charAt(0)&&(r.hash="#"+r.hash):r.hash="",void 0!==t&&void 0===r.state&&(r.state=t));try{r.pathname=decodeURI(r.pathname)}catch(n){throw n instanceof URIError?new URIError('Pathname "'+r.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):n}return e&&(r.key=e),a?r.pathname?"/"!==r.pathname.charAt(0)&&(r.pathname=resolvePathname(r.pathname,a.pathname)):r.pathname=a.pathname:r.pathname||(r.pathname="/"),r}function locationsAreEqual(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash&&n.key===t.key&&valueEqual(n.state,t.state)}function createTransitionManager(){var i=null;var a=[];return{setPrompt:function(n){return i=n,function(){i===n&&(i=null)}},confirmTransitionTo:function(n,t,e,a){if(null!=i){var r="function"==typeof i?i(n,t):i;"string"==typeof r?"function"==typeof e?e(r,a):a(!0):a(!1!==r)}else a(!0)},appendListener:function(n){var t=!0;function e(){t&&n.apply(void 0,arguments)}return a.push(e),function(){t=!1,a=a.filter(function(n){return n!==e})}},notifyListeners:function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];a.forEach(function(n){return n.apply(void 0,t)})}}}var canUseDOM=!("undefined"==typeof window||!window.document||!window.document.createElement);function getConfirmation(n,t){t(window.confirm(n))}function supportsHistory(){var n=window.navigator.userAgent;return(-1===n.indexOf("Android 2.")&&-1===n.indexOf("Android 4.0")||-1===n.indexOf("Mobile Safari")||-1!==n.indexOf("Chrome")||-1!==n.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}function supportsPopStateOnHashChange(){return-1===window.navigator.userAgent.indexOf("Trident")}function supportsGoWithoutReloadUsingHash(){return-1===window.navigator.userAgent.indexOf("Firefox")}function isExtraneousPopstateEvent(n){return void 0===n.state&&-1===navigator.userAgent.indexOf("CriOS")}var PopStateEvent="popstate",HashChangeEvent="hashchange";function getHistoryState(){try{return window.history.state||{}}catch(n){return{}}}function createBrowserHistory(n){void 0===n&&(n={}),canUseDOM||invariant(!1);var s=window.history,c=supportsHistory(),t=!supportsPopStateOnHashChange(),e=n,a=e.forceRefresh,h=void 0!==a&&a,u=e.pathInQuery,r=e.getUserConfirmation,f=void 0===r?getConfirmation:r,i=e.keyLength,o=void 0===i?6:i,d=n.basename?stripTrailingSlash(addLeadingSlash(n.basename)):"",l="/";function p(n){var t=n||{},e=t.key,a=t.state,r=window.location,i=r.search,o=r.hash;l=window.location.pathname||"/";var s=(u?addLeadingSlash(parseQuery(i)[u]||""):l)+i+o;return d&&(s=stripBasename(s,d)),createLocation(s,a,e)}function v(){return Math.random().toString(36).substr(2,o)}var g=createTransitionManager();function m(n){_extends(A,n),A.length=s.length,g.notifyListeners(A.location,A.action)}function P(n){isExtraneousPopstateEvent(n)||H(p(n.state))}function y(){H(p(getHistoryState()))}var w=!1;function H(t){if(w)w=!1,m();else{g.confirmTransitionTo(t,"POP",f,function(n){n?m({action:"POP",location:t}):function(n){var t=A.location,e=L.indexOf(t.key);-1===e&&(e=0);var a=L.indexOf(n.key);-1===a&&(a=0);var r=e-a;r&&(w=!0,S(r))}(t)})}}var x=p(getHistoryState()),L=[x.key];function O(n){if(u){var t=parseQuery(n.search);return t[u]=stripTrailingSlash(stripLeadingSlash(d+n.pathname)),createPath(_extends({},n,{pathname:l,search:"?"+formatQuery(t)}))}return d+createPath(n)}function S(n){s.go(n)}var E=0;function b(n){1===(E+=n)&&1===n?(window.addEventListener(PopStateEvent,P),t&&window.addEventListener(HashChangeEvent,y)):0===E&&(window.removeEventListener(PopStateEvent,P),t&&window.removeEventListener(HashChangeEvent,y))}var T=!1;var A={length:s.length,action:"POP",location:x,createHref:O,push:function(n,t){var o=createLocation(n,t,v(),A.location);g.confirmTransitionTo(o,"PUSH",f,function(n){if(n){var t=O(o),e=o.key,a=o.state;if(c)if(s.pushState({key:e,state:a},null,t),h)window.location.href=t;else{var r=L.indexOf(A.location.key),i=L.slice(0,r+1);i.push(o.key),L=i,m({action:"PUSH",location:o})}else window.location.href=t}})},replace:function(n,t){var i="REPLACE",o=createLocation(n,t,v(),A.location);g.confirmTransitionTo(o,i,f,function(n){if(n){var t=O(o),e=o.key,a=o.state;if(c)if(s.replaceState({key:e,state:a},null,t),h)window.location.replace(t);else{var r=L.indexOf(A.location.key);-1!==r&&(L[r]=o.key),m({action:i,location:o})}else window.location.replace(t)}})},go:S,goBack:function(){S(-1)},goForward:function(){S(1)},block:function(n){void 0===n&&(n=!1);var t=g.setPrompt(n);return T||(b(1),T=!0),function(){return T&&(T=!1,b(-1)),t()}},listen:function(n){var t=g.appendListener(n);return b(1),function(){b(-1),t()}}};return A}var HashChangeEvent$1="hashchange",HashPathCoders={hashbang:{encodePath:function(n){return"!"===n.charAt(0)?n:"!/"+stripLeadingSlash(n)},decodePath:function(n){return"!"===n.charAt(0)?n.substr(1):n}},noslash:{encodePath:stripLeadingSlash,decodePath:addLeadingSlash},slash:{encodePath:addLeadingSlash,decodePath:addLeadingSlash}};function stripHash(n){var t=n.indexOf("#");return-1===t?n:n.slice(0,t)}function getHashPath(){var n=window.location.href,t=n.indexOf("#");return-1===t?"":n.substring(t+1)}function pushHashPath(n){window.location.hash=n}function replaceHashPath(n){window.location.replace(stripHash(window.location.href)+"#"+n)}function createHashHistory(n){void 0===n&&(n={}),canUseDOM||invariant(!1);var t=window.history,e=(supportsGoWithoutReloadUsingHash(),n),a=e.getUserConfirmation,o=void 0===a?getConfirmation:a,r=e.hashType,i=void 0===r?"slash":r,s=n.basename?stripTrailingSlash(addLeadingSlash(n.basename)):"",c=HashPathCoders[i],h=c.encodePath,u=c.decodePath;function f(){var n=u(getHashPath());return s&&(n=stripBasename(n,s)),createLocation(n)}var d=createTransitionManager();function l(n){_extends(S,n),S.length=t.length,d.notifyListeners(S.location,S.action)}var p=!1,v=null;function g(){var n=getHashPath(),t=h(n);if(n!==t)replaceHashPath(t);else{var e=f(),a=S.location;if(!p&&function(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash}(a,e))return;if(v===createPath(e))return;v=null,function(t){if(p)p=!1,l();else{d.confirmTransitionTo(t,"POP",o,function(n){n?l({action:"POP",location:t}):function(n){var t=S.location,e=w.lastIndexOf(createPath(t));-1===e&&(e=0);var a=w.lastIndexOf(createPath(n));-1===a&&(a=0);var r=e-a;r&&(p=!0,H(r))}(t)})}}(e)}}var m=getHashPath(),P=h(m);m!==P&&replaceHashPath(P);var y=f(),w=[createPath(y)];function H(n){t.go(n)}var x=0;function L(n){1===(x+=n)&&1===n?window.addEventListener(HashChangeEvent$1,g):0===x&&window.removeEventListener(HashChangeEvent$1,g)}var O=!1;var S={length:t.length,action:"POP",location:y,createHref:function(n){var t=document.querySelector("base"),e="";return t&&t.getAttribute("href")&&(e=stripHash(window.location.href)),e+"#"+h(s+createPath(n))},push:function(n,t){var i=createLocation(n,void 0,void 0,S.location);d.confirmTransitionTo(i,"PUSH",o,function(n){if(n){var t=createPath(i),e=h(s+t);if(getHashPath()!==e){v=t,pushHashPath(e);var a=w.lastIndexOf(createPath(S.location)),r=w.slice(0,a+1);r.push(t),w=r,l({action:"PUSH",location:i})}else l()}})},replace:function(n,t){var r="REPLACE",i=createLocation(n,void 0,void 0,S.location);d.confirmTransitionTo(i,r,o,function(n){if(n){var t=createPath(i),e=h(s+t);getHashPath()!==e&&(v=t,replaceHashPath(e));var a=w.indexOf(createPath(S.location));-1!==a&&(w[a]=t),l({action:r,location:i})}})},go:H,goBack:function(){H(-1)},goForward:function(){H(1)},block:function(n){void 0===n&&(n=!1);var t=d.setPrompt(n);return O||(L(1),O=!0),function(){return O&&(O=!1,L(-1)),t()}},listen:function(n){var t=d.appendListener(n);return L(1),function(){L(-1),t()}}};return S}function clamp(n,t,e){return Math.min(Math.max(n,t),e)}function createMemoryHistory(n){void 0===n&&(n={});var t=n,r=t.getUserConfirmation,e=t.initialEntries,a=void 0===e?["/"]:e,i=t.initialIndex,o=void 0===i?0:i,s=t.keyLength,c=void 0===s?6:s,h=createTransitionManager();function u(n){_extends(g,n),g.length=g.entries.length,h.notifyListeners(g.location,g.action)}function f(){return Math.random().toString(36).substr(2,c)}var d=clamp(o,0,a.length-1),l=a.map(function(n){return createLocation(n,void 0,"string"==typeof n?f():n.key||f())}),p=createPath;function v(n){var t=clamp(g.index+n,0,g.entries.length-1),e=g.entries[t];h.confirmTransitionTo(e,"POP",r,function(n){n?u({action:"POP",location:e,index:t}):u()})}var g={length:l.length,action:"POP",location:l[d],index:d,entries:l,createHref:p,push:function(n,t){var a=createLocation(n,t,f(),g.location);h.confirmTransitionTo(a,"PUSH",r,function(n){if(n){var t=g.index+1,e=g.entries.slice(0);e.length>t?e.splice(t,e.length-t,a):e.push(a),u({action:"PUSH",location:a,index:t,entries:e})}})},replace:function(n,t){var e="REPLACE",a=createLocation(n,t,f(),g.location);h.confirmTransitionTo(a,e,r,function(n){n&&(g.entries[g.index]=a,u({action:e,location:a}))})},go:v,goBack:function(){v(-1)},goForward:function(){v(1)},canGo:function(n){var t=g.index+n;return 0<=t&&t<g.entries.length},block:function(n){return void 0===n&&(n=!1),h.setPrompt(n)},listen:function(n){return h.appendListener(n)}};return g}exports.createBrowserHistory=createBrowserHistory,exports.createHashHistory=createHashHistory,exports.createMemoryHistory=createMemoryHistory,exports.createLocation=createLocation,exports.locationsAreEqual=locationsAreEqual,exports.parsePath=parsePath,exports.createPath=createPath;

@@ -360,3 +360,3 @@ import _extends from '@babel/runtime/helpers/esm/extends';

domPathname = window.location.pathname || '/';
var pathname = pathInQuery ? parseQuery(search)[pathInQuery] || '/' : domPathname;
var pathname = pathInQuery ? addLeadingSlash(parseQuery(search)[pathInQuery] || '') : domPathname;
var path = pathname + search + hash;

@@ -435,3 +435,3 @@ process.env.NODE_ENV !== "production" ? warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') : void 0;

var query = parseQuery(location.search);
query[pathInQuery] = basename + location.pathname;
query[pathInQuery] = stripTrailingSlash(stripLeadingSlash(basename + location.pathname));
return createPath(_extends({}, location, {

@@ -438,0 +438,0 @@ pathname: domPathname,

{
"name": "@recore/history",
"version": "4.10.2",
"version": "4.11.0",
"description": "Manage session history with JavaScript",

@@ -5,0 +5,0 @@ "repository": "ReactTraining/history",

@@ -516,3 +516,3 @@ (function (global, factory) {

domPathname = window.location.pathname || '/';
var pathname = pathInQuery ? parseQuery(search)[pathInQuery] || '/' : domPathname;
var pathname = pathInQuery ? addLeadingSlash(parseQuery(search)[pathInQuery] || '') : domPathname;
var path = pathname + search + hash;

@@ -591,3 +591,3 @@ warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".');

var query = parseQuery(location.search);
query[pathInQuery] = basename + location.pathname;
query[pathInQuery] = stripTrailingSlash(stripLeadingSlash(basename + location.pathname));
return createPath(_extends({}, location, {

@@ -594,0 +594,0 @@ pathname: domPathname,

@@ -1,1 +0,1 @@

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.History={})}(this,function(n){"use strict";function C(){return(C=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n}).apply(this,arguments)}function d(n){return"/"===n.charAt(0)}function v(n,t){for(var e=t,r=e+1,o=n.length;r<o;e+=1,r+=1)n[e]=n[r];n.pop()}function i(n){return n.valueOf?n.valueOf():Object.prototype.valueOf.call(n)}function H(n){return"/"===n.charAt(0)?n:"/"+n}function t(n){return"/"===n.charAt(0)?n.substr(1):n}function S(n,t){return function(n,t){return 0===n.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(n.charAt(t.length))}(n,t)?n.substr(t.length):n}function j(n){return"/"===n.charAt(n.length-1)?n.slice(0,-1):n}function a(n){var t=n||"/",e="",r="",o=t.indexOf("#");-1!==o&&(r=t.substr(o),t=t.substr(0,o));var i=t.indexOf("?");return-1!==i&&(e=t.substr(i),t=t.substr(0,i)),{pathname:t,search:"?"===e?"":e,hash:"#"===r?"":r}}function I(n){var t=n.pathname,e=n.search,r=n.hash,o=t||"/";return e&&"?"!==e&&(o+="?"===e.charAt(0)?e:"?"+e),r&&"#"!==r&&(o+="#"===r.charAt(0)?r:"#"+r),o}function f(n){return n&&(n=n.replace(/\+/g,"%20"),n=decodeURIComponent(n)),n}function R(n){var t={};if(!n)return t;0===n.indexOf("?")&&(n=n.substring(1));for(var e,r,o,i,a=n.split(/[&;]/),c=0,u=a.length;c<u;c++)0!==(r=(e=a[c]).indexOf("="))&&(i=r<0?(o=e,null):(o=f(e.substring(0,r)),f(e.substring(r+1))),o in t?(Array.isArray(t[o])||(t[o]=[t[o]]),t[o].push(i)):t[o]=i);return t}function M(n){switch(typeof n){case"string":return n;case"boolean":return n?"true":"false";case"number":return isFinite(n)?n:"";default:return""}}function B(n,t,e,r){var o;"string"==typeof n?(o=a(n)).state=t:(void 0===(o=C({},n)).pathname&&(o.pathname=""),o.search?"?"!==o.search.charAt(0)&&(o.search="?"+o.search):o.search="",o.hash?"#"!==o.hash.charAt(0)&&(o.hash="#"+o.hash):o.hash="",void 0!==t&&void 0===o.state&&(o.state=t));try{o.pathname=decodeURI(o.pathname)}catch(n){throw n instanceof URIError?new URIError('Pathname "'+o.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):n}return e&&(o.key=e),r?o.pathname?"/"!==o.pathname.charAt(0)&&(o.pathname=function(n,t){void 0===t&&(t="");var e,r=n&&n.split("/")||[],o=t&&t.split("/")||[],i=n&&d(n),a=t&&d(t),c=i||a;if(n&&d(n)?o=r:r.length&&(o.pop(),o=o.concat(r)),!o.length)return"/";if(o.length){var u=o[o.length-1];e="."===u||".."===u||""===u}else e=!1;for(var f=0,s=o.length;0<=s;s--){var h=o[s];"."===h?v(o,s):".."===h?(v(o,s),f++):f&&(v(o,s),f--)}if(!c)for(;f--;)o.unshift("..");!c||""===o[0]||o[0]&&d(o[0])||o.unshift("");var l=o.join("/");return e&&"/"!==l.substr(-1)&&(l+="/"),l}(o.pathname,r.pathname)):o.pathname=r.pathname:o.pathname||(o.pathname="/"),o}function F(){var i=null;var r=[];return{setPrompt:function(n){return i=n,function(){i===n&&(i=null)}},confirmTransitionTo:function(n,t,e,r){if(null!=i){var o="function"==typeof i?i(n,t):i;"string"==typeof o?"function"==typeof e?e(o,r):r(!0):r(!1!==o)}else r(!0)},appendListener:function(n){var t=!0;function e(){t&&n.apply(void 0,arguments)}return r.push(e),function(){t=!1,r=r.filter(function(n){return n!==e})}},notifyListeners:function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];r.forEach(function(n){return n.apply(void 0,t)})}}}var q=!("undefined"==typeof window||!window.document||!window.document.createElement);function _(n,t){t(window.confirm(n))}var e="Invariant failed";function G(n){if(!n)throw new Error(e)}var Q="popstate",W="hashchange";function z(){try{return window.history.state||{}}catch(n){return{}}}var T="hashchange",L={hashbang:{encodePath:function(n){return"!"===n.charAt(0)?n:"!/"+t(n)},decodePath:function(n){return"!"===n.charAt(0)?n.substr(1):n}},noslash:{encodePath:t,decodePath:H},slash:{encodePath:H,decodePath:H}};function E(n){var t=n.indexOf("#");return-1===t?n:n.slice(0,t)}function U(){var n=window.location.href,t=n.indexOf("#");return-1===t?"":n.substring(t+1)}function D(n){window.location.replace(E(window.location.href)+"#"+n)}function w(n,t,e){return Math.min(Math.max(n,t),e)}n.createBrowserHistory=function(n){void 0===n&&(n={}),q||G(!1);var c=window.history,u=function(){var n=window.navigator.userAgent;return(-1===n.indexOf("Android 2.")&&-1===n.indexOf("Android 4.0")||-1===n.indexOf("Mobile Safari")||-1!==n.indexOf("Chrome")||-1!==n.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}(),t=!(-1===window.navigator.userAgent.indexOf("Trident")),e=n,r=e.forceRefresh,f=void 0!==r&&r,s=e.pathInQuery,o=e.getUserConfirmation,h=void 0===o?_:o,i=e.keyLength,a=void 0===i?6:i,l=n.basename?j(H(n.basename)):"",d="/";function v(n){var t=n||{},e=t.key,r=t.state,o=window.location,i=o.search,a=o.hash;d=window.location.pathname||"/";var c=(s?R(i)[s]||"/":d)+i+a;return l&&(c=S(c,l)),B(c,r,e)}function p(){return Math.random().toString(36).substr(2,a)}var g=F();function w(n){C(U,n),U.length=c.length,g.notifyListeners(U.location,U.action)}function y(n){!function(n){return void 0===n.state&&-1===navigator.userAgent.indexOf("CriOS")}(n)&&P(v(n.state))}function m(){P(v(z()))}var O=!1;function P(t){if(O)O=!1,w();else{g.confirmTransitionTo(t,"POP",h,function(n){n?w({action:"POP",location:t}):function(n){var t=U.location,e=x.indexOf(t.key);-1===e&&(e=0);var r=x.indexOf(n.key);-1===r&&(r=0);var o=e-r;o&&(O=!0,k(o))}(t)})}}var b=v(z()),x=[b.key];function A(n){if(s){var t=R(n.search);return t[s]=l+n.pathname,I(C({},n,{pathname:d,search:"?"+function(e){return Object.keys(e).map(function(n){var t=encodeURIComponent(M(n))+"=";return Array.isArray(e[n])?e[n].map(function(n){return t+encodeURIComponent(M(n))}).join("&"):t+encodeURIComponent(M(e[n]))}).filter(Boolean).join("&")}(t)}))}return l+I(n)}function k(n){c.go(n)}var T=0;function L(n){1===(T+=n)&&1===n?(window.addEventListener(Q,y),t&&window.addEventListener(W,m)):0===T&&(window.removeEventListener(Q,y),t&&window.removeEventListener(W,m))}var E=!1,U={length:c.length,action:"POP",location:b,createHref:A,push:function(n,t){var a=B(n,t,p(),U.location);g.confirmTransitionTo(a,"PUSH",h,function(n){if(n){var t=A(a),e=a.key,r=a.state;if(u)if(c.pushState({key:e,state:r},null,t),f)window.location.href=t;else{var o=x.indexOf(U.location.key),i=x.slice(0,o+1);i.push(a.key),x=i,w({action:"PUSH",location:a})}else window.location.href=t}})},replace:function(n,t){var i="REPLACE",a=B(n,t,p(),U.location);g.confirmTransitionTo(a,i,h,function(n){if(n){var t=A(a),e=a.key,r=a.state;if(u)if(c.replaceState({key:e,state:r},null,t),f)window.location.replace(t);else{var o=x.indexOf(U.location.key);-1!==o&&(x[o]=a.key),w({action:i,location:a})}else window.location.replace(t)}})},go:k,goBack:function(){k(-1)},goForward:function(){k(1)},block:function(n){void 0===n&&(n=!1);var t=g.setPrompt(n);return E||(L(1),E=!0),function(){return E&&(E=!1,L(-1)),t()}},listen:function(n){var t=g.appendListener(n);return L(1),function(){L(-1),t()}}};return U},n.createHashHistory=function(n){void 0===n&&(n={}),q||G(!1);var t=window.history,e=(window.navigator.userAgent.indexOf("Firefox"),n),r=e.getUserConfirmation,a=void 0===r?_:r,o=e.hashType,i=void 0===o?"slash":o,c=n.basename?j(H(n.basename)):"",u=L[i],f=u.encodePath,s=u.decodePath;function h(){var n=s(U());return c&&(n=S(n,c)),B(n)}var l=F();function d(n){C(k,n),k.length=t.length,l.notifyListeners(k.location,k.action)}var v=!1,p=null;function g(){var n=U(),t=f(n);if(n!==t)D(t);else{var e=h(),r=k.location;if(!v&&function(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash}(r,e))return;if(p===I(e))return;p=null,function(t){if(v)v=!1,d();else{l.confirmTransitionTo(t,"POP",a,function(n){n?d({action:"POP",location:t}):function(n){var t=k.location,e=O.lastIndexOf(I(t));-1===e&&(e=0);var r=O.lastIndexOf(I(n));-1===r&&(r=0);var o=e-r;o&&(v=!0,P(o))}(t)})}}(e)}}var w=U(),y=f(w);w!==y&&D(y);var m=h(),O=[I(m)];function P(n){t.go(n)}var b=0;function x(n){1===(b+=n)&&1===n?window.addEventListener(T,g):0===b&&window.removeEventListener(T,g)}var A=!1,k={length:t.length,action:"POP",location:m,createHref:function(n){var t=document.querySelector("base"),e="";return t&&t.getAttribute("href")&&(e=E(window.location.href)),e+"#"+f(c+I(n))},push:function(n,t){var i=B(n,void 0,void 0,k.location);l.confirmTransitionTo(i,"PUSH",a,function(n){if(n){var t=I(i),e=f(c+t);if(U()!==e){p=t,function(n){window.location.hash=n}(e);var r=O.lastIndexOf(I(k.location)),o=O.slice(0,r+1);o.push(t),O=o,d({action:"PUSH",location:i})}else d()}})},replace:function(n,t){var o="REPLACE",i=B(n,void 0,void 0,k.location);l.confirmTransitionTo(i,o,a,function(n){if(n){var t=I(i),e=f(c+t);U()!==e&&(p=t,D(e));var r=O.indexOf(I(k.location));-1!==r&&(O[r]=t),d({action:o,location:i})}})},go:P,goBack:function(){P(-1)},goForward:function(){P(1)},block:function(n){void 0===n&&(n=!1);var t=l.setPrompt(n);return A||(x(1),A=!0),function(){return A&&(A=!1,x(-1)),t()}},listen:function(n){var t=l.appendListener(n);return x(1),function(){x(-1),t()}}};return k},n.createMemoryHistory=function(n){void 0===n&&(n={});var t=n,o=t.getUserConfirmation,e=t.initialEntries,r=void 0===e?["/"]:e,i=t.initialIndex,a=void 0===i?0:i,c=t.keyLength,u=void 0===c?6:c,f=F();function s(n){C(g,n),g.length=g.entries.length,f.notifyListeners(g.location,g.action)}function h(){return Math.random().toString(36).substr(2,u)}var l=w(a,0,r.length-1),d=r.map(function(n){return B(n,void 0,"string"==typeof n?h():n.key||h())}),v=I;function p(n){var t=w(g.index+n,0,g.entries.length-1),e=g.entries[t];f.confirmTransitionTo(e,"POP",o,function(n){n?s({action:"POP",location:e,index:t}):s()})}var g={length:d.length,action:"POP",location:d[l],index:l,entries:d,createHref:v,push:function(n,t){var r=B(n,t,h(),g.location);f.confirmTransitionTo(r,"PUSH",o,function(n){if(n){var t=g.index+1,e=g.entries.slice(0);e.length>t?e.splice(t,e.length-t,r):e.push(r),s({action:"PUSH",location:r,index:t,entries:e})}})},replace:function(n,t){var e="REPLACE",r=B(n,t,h(),g.location);f.confirmTransitionTo(r,e,o,function(n){n&&(g.entries[g.index]=r,s({action:e,location:r}))})},go:p,goBack:function(){p(-1)},goForward:function(){p(1)},canGo:function(n){var t=g.index+n;return 0<=t&&t<g.entries.length},block:function(n){return void 0===n&&(n=!1),f.setPrompt(n)},listen:function(n){return f.appendListener(n)}};return g},n.createLocation=B,n.locationsAreEqual=function(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash&&n.key===t.key&&function e(t,r){if(t===r)return!0;if(null==t||null==r)return!1;if(Array.isArray(t))return Array.isArray(r)&&t.length===r.length&&t.every(function(n,t){return e(n,r[t])});if("object"!=typeof t&&"object"!=typeof r)return!1;var n=i(t),o=i(r);return n!==t||o!==r?e(n,o):Object.keys(Object.assign({},t,r)).every(function(n){return e(t[n],r[n])})}(n.state,t.state)},n.parsePath=a,n.createPath=I,Object.defineProperty(n,"__esModule",{value:!0})});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.History={})}(this,function(n){"use strict";function C(){return(C=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n}).apply(this,arguments)}function d(n){return"/"===n.charAt(0)}function v(n,t){for(var e=t,r=e+1,o=n.length;r<o;e+=1,r+=1)n[e]=n[r];n.pop()}function i(n){return n.valueOf?n.valueOf():Object.prototype.valueOf.call(n)}function H(n){return"/"===n.charAt(0)?n:"/"+n}function S(n){return"/"===n.charAt(0)?n.substr(1):n}function j(n,t){return function(n,t){return 0===n.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(n.charAt(t.length))}(n,t)?n.substr(t.length):n}function I(n){return"/"===n.charAt(n.length-1)?n.slice(0,-1):n}function a(n){var t=n||"/",e="",r="",o=t.indexOf("#");-1!==o&&(r=t.substr(o),t=t.substr(0,o));var i=t.indexOf("?");return-1!==i&&(e=t.substr(i),t=t.substr(0,i)),{pathname:t,search:"?"===e?"":e,hash:"#"===r?"":r}}function R(n){var t=n.pathname,e=n.search,r=n.hash,o=t||"/";return e&&"?"!==e&&(o+="?"===e.charAt(0)?e:"?"+e),r&&"#"!==r&&(o+="#"===r.charAt(0)?r:"#"+r),o}function f(n){return n&&(n=n.replace(/\+/g,"%20"),n=decodeURIComponent(n)),n}function M(n){var t={};if(!n)return t;0===n.indexOf("?")&&(n=n.substring(1));for(var e,r,o,i,a=n.split(/[&;]/),c=0,u=a.length;c<u;c++)0!==(r=(e=a[c]).indexOf("="))&&(i=r<0?(o=e,null):(o=f(e.substring(0,r)),f(e.substring(r+1))),o in t?(Array.isArray(t[o])||(t[o]=[t[o]]),t[o].push(i)):t[o]=i);return t}function B(n){switch(typeof n){case"string":return n;case"boolean":return n?"true":"false";case"number":return isFinite(n)?n:"";default:return""}}function F(n,t,e,r){var o;"string"==typeof n?(o=a(n)).state=t:(void 0===(o=C({},n)).pathname&&(o.pathname=""),o.search?"?"!==o.search.charAt(0)&&(o.search="?"+o.search):o.search="",o.hash?"#"!==o.hash.charAt(0)&&(o.hash="#"+o.hash):o.hash="",void 0!==t&&void 0===o.state&&(o.state=t));try{o.pathname=decodeURI(o.pathname)}catch(n){throw n instanceof URIError?new URIError('Pathname "'+o.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):n}return e&&(o.key=e),r?o.pathname?"/"!==o.pathname.charAt(0)&&(o.pathname=function(n,t){void 0===t&&(t="");var e,r=n&&n.split("/")||[],o=t&&t.split("/")||[],i=n&&d(n),a=t&&d(t),c=i||a;if(n&&d(n)?o=r:r.length&&(o.pop(),o=o.concat(r)),!o.length)return"/";if(o.length){var u=o[o.length-1];e="."===u||".."===u||""===u}else e=!1;for(var f=0,s=o.length;0<=s;s--){var h=o[s];"."===h?v(o,s):".."===h?(v(o,s),f++):f&&(v(o,s),f--)}if(!c)for(;f--;)o.unshift("..");!c||""===o[0]||o[0]&&d(o[0])||o.unshift("");var l=o.join("/");return e&&"/"!==l.substr(-1)&&(l+="/"),l}(o.pathname,r.pathname)):o.pathname=r.pathname:o.pathname||(o.pathname="/"),o}function q(){var i=null;var r=[];return{setPrompt:function(n){return i=n,function(){i===n&&(i=null)}},confirmTransitionTo:function(n,t,e,r){if(null!=i){var o="function"==typeof i?i(n,t):i;"string"==typeof o?"function"==typeof e?e(o,r):r(!0):r(!1!==o)}else r(!0)},appendListener:function(n){var t=!0;function e(){t&&n.apply(void 0,arguments)}return r.push(e),function(){t=!1,r=r.filter(function(n){return n!==e})}},notifyListeners:function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];r.forEach(function(n){return n.apply(void 0,t)})}}}var _=!("undefined"==typeof window||!window.document||!window.document.createElement);function G(n,t){t(window.confirm(n))}var t="Invariant failed";function Q(n){if(!n)throw new Error(t)}var W="popstate",z="hashchange";function D(){try{return window.history.state||{}}catch(n){return{}}}var T="hashchange",L={hashbang:{encodePath:function(n){return"!"===n.charAt(0)?n:"!/"+S(n)},decodePath:function(n){return"!"===n.charAt(0)?n.substr(1):n}},noslash:{encodePath:S,decodePath:H},slash:{encodePath:H,decodePath:H}};function E(n){var t=n.indexOf("#");return-1===t?n:n.slice(0,t)}function U(){var n=window.location.href,t=n.indexOf("#");return-1===t?"":n.substring(t+1)}function J(n){window.location.replace(E(window.location.href)+"#"+n)}function w(n,t,e){return Math.min(Math.max(n,t),e)}n.createBrowserHistory=function(n){void 0===n&&(n={}),_||Q(!1);var c=window.history,u=function(){var n=window.navigator.userAgent;return(-1===n.indexOf("Android 2.")&&-1===n.indexOf("Android 4.0")||-1===n.indexOf("Mobile Safari")||-1!==n.indexOf("Chrome")||-1!==n.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}(),t=!(-1===window.navigator.userAgent.indexOf("Trident")),e=n,r=e.forceRefresh,f=void 0!==r&&r,s=e.pathInQuery,o=e.getUserConfirmation,h=void 0===o?G:o,i=e.keyLength,a=void 0===i?6:i,l=n.basename?I(H(n.basename)):"",d="/";function v(n){var t=n||{},e=t.key,r=t.state,o=window.location,i=o.search,a=o.hash;d=window.location.pathname||"/";var c=(s?H(M(i)[s]||""):d)+i+a;return l&&(c=j(c,l)),F(c,r,e)}function p(){return Math.random().toString(36).substr(2,a)}var g=q();function w(n){C(U,n),U.length=c.length,g.notifyListeners(U.location,U.action)}function y(n){!function(n){return void 0===n.state&&-1===navigator.userAgent.indexOf("CriOS")}(n)&&P(v(n.state))}function m(){P(v(D()))}var O=!1;function P(t){if(O)O=!1,w();else{g.confirmTransitionTo(t,"POP",h,function(n){n?w({action:"POP",location:t}):function(n){var t=U.location,e=x.indexOf(t.key);-1===e&&(e=0);var r=x.indexOf(n.key);-1===r&&(r=0);var o=e-r;o&&(O=!0,k(o))}(t)})}}var b=v(D()),x=[b.key];function A(n){if(s){var t=M(n.search);return t[s]=I(S(l+n.pathname)),R(C({},n,{pathname:d,search:"?"+function(e){return Object.keys(e).map(function(n){var t=encodeURIComponent(B(n))+"=";return Array.isArray(e[n])?e[n].map(function(n){return t+encodeURIComponent(B(n))}).join("&"):t+encodeURIComponent(B(e[n]))}).filter(Boolean).join("&")}(t)}))}return l+R(n)}function k(n){c.go(n)}var T=0;function L(n){1===(T+=n)&&1===n?(window.addEventListener(W,y),t&&window.addEventListener(z,m)):0===T&&(window.removeEventListener(W,y),t&&window.removeEventListener(z,m))}var E=!1,U={length:c.length,action:"POP",location:b,createHref:A,push:function(n,t){var a=F(n,t,p(),U.location);g.confirmTransitionTo(a,"PUSH",h,function(n){if(n){var t=A(a),e=a.key,r=a.state;if(u)if(c.pushState({key:e,state:r},null,t),f)window.location.href=t;else{var o=x.indexOf(U.location.key),i=x.slice(0,o+1);i.push(a.key),x=i,w({action:"PUSH",location:a})}else window.location.href=t}})},replace:function(n,t){var i="REPLACE",a=F(n,t,p(),U.location);g.confirmTransitionTo(a,i,h,function(n){if(n){var t=A(a),e=a.key,r=a.state;if(u)if(c.replaceState({key:e,state:r},null,t),f)window.location.replace(t);else{var o=x.indexOf(U.location.key);-1!==o&&(x[o]=a.key),w({action:i,location:a})}else window.location.replace(t)}})},go:k,goBack:function(){k(-1)},goForward:function(){k(1)},block:function(n){void 0===n&&(n=!1);var t=g.setPrompt(n);return E||(L(1),E=!0),function(){return E&&(E=!1,L(-1)),t()}},listen:function(n){var t=g.appendListener(n);return L(1),function(){L(-1),t()}}};return U},n.createHashHistory=function(n){void 0===n&&(n={}),_||Q(!1);var t=window.history,e=(window.navigator.userAgent.indexOf("Firefox"),n),r=e.getUserConfirmation,a=void 0===r?G:r,o=e.hashType,i=void 0===o?"slash":o,c=n.basename?I(H(n.basename)):"",u=L[i],f=u.encodePath,s=u.decodePath;function h(){var n=s(U());return c&&(n=j(n,c)),F(n)}var l=q();function d(n){C(k,n),k.length=t.length,l.notifyListeners(k.location,k.action)}var v=!1,p=null;function g(){var n=U(),t=f(n);if(n!==t)J(t);else{var e=h(),r=k.location;if(!v&&function(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash}(r,e))return;if(p===R(e))return;p=null,function(t){if(v)v=!1,d();else{l.confirmTransitionTo(t,"POP",a,function(n){n?d({action:"POP",location:t}):function(n){var t=k.location,e=O.lastIndexOf(R(t));-1===e&&(e=0);var r=O.lastIndexOf(R(n));-1===r&&(r=0);var o=e-r;o&&(v=!0,P(o))}(t)})}}(e)}}var w=U(),y=f(w);w!==y&&J(y);var m=h(),O=[R(m)];function P(n){t.go(n)}var b=0;function x(n){1===(b+=n)&&1===n?window.addEventListener(T,g):0===b&&window.removeEventListener(T,g)}var A=!1,k={length:t.length,action:"POP",location:m,createHref:function(n){var t=document.querySelector("base"),e="";return t&&t.getAttribute("href")&&(e=E(window.location.href)),e+"#"+f(c+R(n))},push:function(n,t){var i=F(n,void 0,void 0,k.location);l.confirmTransitionTo(i,"PUSH",a,function(n){if(n){var t=R(i),e=f(c+t);if(U()!==e){p=t,function(n){window.location.hash=n}(e);var r=O.lastIndexOf(R(k.location)),o=O.slice(0,r+1);o.push(t),O=o,d({action:"PUSH",location:i})}else d()}})},replace:function(n,t){var o="REPLACE",i=F(n,void 0,void 0,k.location);l.confirmTransitionTo(i,o,a,function(n){if(n){var t=R(i),e=f(c+t);U()!==e&&(p=t,J(e));var r=O.indexOf(R(k.location));-1!==r&&(O[r]=t),d({action:o,location:i})}})},go:P,goBack:function(){P(-1)},goForward:function(){P(1)},block:function(n){void 0===n&&(n=!1);var t=l.setPrompt(n);return A||(x(1),A=!0),function(){return A&&(A=!1,x(-1)),t()}},listen:function(n){var t=l.appendListener(n);return x(1),function(){x(-1),t()}}};return k},n.createMemoryHistory=function(n){void 0===n&&(n={});var t=n,o=t.getUserConfirmation,e=t.initialEntries,r=void 0===e?["/"]:e,i=t.initialIndex,a=void 0===i?0:i,c=t.keyLength,u=void 0===c?6:c,f=q();function s(n){C(g,n),g.length=g.entries.length,f.notifyListeners(g.location,g.action)}function h(){return Math.random().toString(36).substr(2,u)}var l=w(a,0,r.length-1),d=r.map(function(n){return F(n,void 0,"string"==typeof n?h():n.key||h())}),v=R;function p(n){var t=w(g.index+n,0,g.entries.length-1),e=g.entries[t];f.confirmTransitionTo(e,"POP",o,function(n){n?s({action:"POP",location:e,index:t}):s()})}var g={length:d.length,action:"POP",location:d[l],index:l,entries:d,createHref:v,push:function(n,t){var r=F(n,t,h(),g.location);f.confirmTransitionTo(r,"PUSH",o,function(n){if(n){var t=g.index+1,e=g.entries.slice(0);e.length>t?e.splice(t,e.length-t,r):e.push(r),s({action:"PUSH",location:r,index:t,entries:e})}})},replace:function(n,t){var e="REPLACE",r=F(n,t,h(),g.location);f.confirmTransitionTo(r,e,o,function(n){n&&(g.entries[g.index]=r,s({action:e,location:r}))})},go:p,goBack:function(){p(-1)},goForward:function(){p(1)},canGo:function(n){var t=g.index+n;return 0<=t&&t<g.entries.length},block:function(n){return void 0===n&&(n=!1),f.setPrompt(n)},listen:function(n){return f.appendListener(n)}};return g},n.createLocation=F,n.locationsAreEqual=function(n,t){return n.pathname===t.pathname&&n.search===t.search&&n.hash===t.hash&&n.key===t.key&&function e(t,r){if(t===r)return!0;if(null==t||null==r)return!1;if(Array.isArray(t))return Array.isArray(r)&&t.length===r.length&&t.every(function(n,t){return e(n,r[t])});if("object"!=typeof t&&"object"!=typeof r)return!1;var n=i(t),o=i(r);return n!==t||o!==r?e(n,o):Object.keys(Object.assign({},t,r)).every(function(n){return e(t[n],r[n])})}(n.state,t.state)},n.parsePath=a,n.createPath=R,Object.defineProperty(n,"__esModule",{value:!0})});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc