Socket
Socket
Sign inDemoInstall

vue-router

Package Overview
Dependencies
Maintainers
1
Versions
185
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-router - npm Package Compare versions

Comparing version 2.0.0-beta.3 to 2.0.0-beta.4

12

dist/vue-router.js

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

this.router = router
this.base = normalizeBae(base)
this.base = normalizeBase(base)
// start with a route object that stands for "nowhere"

@@ -1251,7 +1251,3 @@ this.current = createRoute(null, {

History.prototype.getLocation = function getLocation () {
return '/'
};
function normalizeBae (base ) {
function normalizeBase (base ) {
if (!base) {

@@ -1485,3 +1481,3 @@ if (inBrowser) {

}
return path + window.location.search + window.location.hash
return (path || '/') + window.location.search + window.location.hash
}

@@ -1519,2 +1515,3 @@

}
ensureSlash()
window.addEventListener('hashchange', function () {

@@ -1530,3 +1527,2 @@ this$1.onHashChange()

HashHistory.prototype.onInit = function onInit () {
ensureSlash()
// possible redirect on start

@@ -1533,0 +1529,0 @@ if (getHash() !== this.current.fullPath) {

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueRouter=e()}(this,function(){"use strict";function t(t,e,n){if("/"===t.charAt(0))return t;if("?"===t.charAt(0)||"#"===t.charAt(0))return e+t;var r=e.split("/");n&&r[r.length-1]||r.pop();for(var o=t.replace(/^\//,"").split("/"),i=0;i<o.length;i++){var a=o[i];"."!==a&&(".."===a?r.pop():r.push(a))}return""!==r[0]&&r.unshift(""),r.join("/")}function e(t){var e="",n="",r=t.indexOf("#");r>=0&&(e=t.slice(r),t=t.slice(0,r));var o=t.indexOf("?");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{path:t,query:n,hash:e}}function n(t){return t.replace(/\/\//g,"/")}function r(t,e){return!!e&&(t.path&&e.path?t.path===e.path&&t.hash===e.hash&&o(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&o(t.query,e.query)&&o(t.params,e.params)))}function o(t,e){void 0===t&&(t={}),void 0===e&&(e={});var n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(function(n){return String(t[n])===String(e[n])})}function i(t,e){return 0===t.path.indexOf(e.path)&&(!e.hash||t.hash===e.hash)&&a(t.query,e.query)}function a(t,e){for(var n in e)if(!(n in t))return!1;return!0}function u(t,e){if(!t)throw new Error("[vue-router] "+e)}function c(t,e){t||"undefined"!=typeof console&&console.warn("[vue-router] "+e)}function s(t,e){if(void 0===e&&(e={}),t){var n;try{n=p(t)}catch(t){c(!1,t.message),n={}}for(var r in e)n[r]=e[r];return n}return e}function p(t){var e=Object.create(null);return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(function(t){var n=t.replace(/\+/g," ").split("="),r=Y(n.shift()),o=n.length>0?Y(n.join("=")):null;void 0===e[r]?e[r]=o:Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]}),e):e}function f(t){var e=t?Object.keys(t).sort().map(function(e){var n=t[e];if(void 0===n)return"";if(null===n)return X(e);if(Array.isArray(n)){var r=[];return n.slice().forEach(function(t){void 0!==t&&(null===t?r.push(X(e)):r.push(X(e)+"="+X(t)))}),r.join("&")}return X(e)+"="+X(n)}).filter(function(t){return t.length>0}).join("&"):null;return e?"?"+e:""}function h(n,r,o){var i="string"==typeof n?{path:n}:n;if(i.name||i._normalized)return i;var a=e(i.path||""),u=r&&r.path||"/",c=a.path?t(a.path,u,o):r&&r.path||"/",p=s(a.query,i.query),f=i.hash||a.hash;return f&&"#"!==f.charAt(0)&&(f="#"+f),{_normalized:!0,path:c,query:p,hash:f}}function l(t){if(t)for(var e,n=0;n<t.length;n++){if(e=t[n],"a"===e.tag)return e;if(e.children&&(e=l(e.children)))return e}}function d(t){d.installed||(d.installed=!0,Object.defineProperty(t.prototype,"$router",{get:function(){return this.$root._router}}),Object.defineProperty(t.prototype,"$route",{get:function(){return this.$root._route}}),t.mixin({beforeCreate:function(){this.$options.router&&(this._router=this.$options.router,this._router.init(this),t.util.defineReactive(this,"_route",this._router.history.current))}}),t.component("router-view",D),t.component("router-link",W))}function y(t){return t&&"object"==typeof t&&"default"in t?t.default:t}function v(t,e){return e={exports:{}},t(e,e.exports),e.exports}function m(t){var e=Object.create(null),n=Object.create(null);return t.forEach(function(t){g(e,n,t)}),{pathMap:e,nameMap:n}}function g(t,e,n,r,o){var i=n.path,a=n.name;u(null!=i,'"path" is required in a route configuration.');var c={path:w(i,r),components:n.components||{default:n.component},instances:{},name:a,parent:r,matchAs:o,redirect:n.redirect,beforeEnter:n.beforeEnter,meta:n.meta||{}};n.children&&n.children.forEach(function(n){g(t,e,n,c)}),n.alias&&(Array.isArray(n.alias)?n.alias.forEach(function(n){g(t,e,{path:n},r,c.path)}):g(t,e,{path:n.alias},r,c.path)),t[c.path]=c,a&&(e[a]=c)}function w(t,e){return t=t.replace(/\/$/,""),"/"===t[0]?t:null==e?t:n(e.path+"/"+t)}function b(t){function e(t,e,n){var r=h(t,e),i=r.name;if(i){var u=s[i];if(u)return r.path=O(u.path,r.params,'named route "'+i+'"'),o(u,r,n)}else if(r.path){r.params={};for(var c in a)if(k(c,r.params,r.path))return o(a[c],r,n)}return o(null,r)}function n(t,n){var r=n.query,i=n.hash,a=n.params,p=t.redirect,f=p&&"object"==typeof p&&p.name;if(f){var h=s[f];return u(h,'redirect failed: named route "'+f+'" not found.'),e({_normalized:!0,name:f,query:r,hash:i,params:a},void 0,n)}if("string"==typeof p){var l=E(p,t),d=O(l,a,'redirect route with path "'+l+'"');return e({_normalized:!0,path:d,query:r,hash:i},void 0,n)}return c(!1,"invalid redirect option: "+JSON.stringify(p)),o(null,n)}function r(t,n,r){var i=O(r,n.params,'aliased route with path "'+r+'"'),a=e({_normalized:!0,path:i});if(a){var u=a.matched,c=u[u.length-1];return n.params=a.params,o(c,n)}return o(null,n)}function o(t,e,o){return t&&t.redirect?n(t,o||e):t&&t.matchAs?r(t,e,t.matchAs):x(t,e,o)}var i=m(t),a=i.pathMap,s=i.nameMap;return e}function x(t,e,n){var r={name:e.name,path:e.path||"/",hash:e.hash||"",query:e.query||{},params:e.params||{},fullPath:j(e),matched:t?_(t):[]};return n&&(r.redirectedFrom=j(n)),Object.freeze(r)}function k(t,e,n){var r,o,i=et[t];i?(r=i.keys,o=i.regexp):(r=[],o=tt(t,r),et[t]={keys:r,regexp:o});var a=n.match(o);if(!a)return!1;if(!e)return!0;for(var u=1,c=a.length;u<c;++u){var s=r[u-1],p="string"==typeof a[u]?decodeURIComponent(a[u]):a[u];s&&(e[s.name]=p)}return!0}function O(t,e,n){try{var r=nt[t]||(nt[t]=tt.compile(t));return r(e||{},{pretty:!0})}catch(t){return u(!1,"missing param for "+n+": "+t.message),""}}function _(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function E(e,n){return t(e,n.parent?n.parent.path:"/",!0)}function j(t){var e=t.path,n=t.query;void 0===n&&(n={});var r=t.hash;return void 0===r&&(r=""),(e||"/")+f(n)+r}function A(t,e,n){var r=function(o){o>=t.length?n():e(t[o],function(){r(o+1)})};r(0)}function S(t){if(!t)if(rt){var e=document.querySelector("base");t=e?e.getAttribute("href"):"/"}else t="/";return"/"!==t.charAt(0)&&(t="/"+t),t.replace(/\/$/,"")}function $(t,e){var n,r=Math.max(t.length,e.length);for(n=0;n<r&&t[n]===e[n];n++);return{activated:e.slice(n),deactivated:t.slice(n)}}function R(t){return q(t,function(t,e){var n=t&&t.beforeRouteLeave;if(n)return function(){return n.apply(e,arguments)}}).reverse()}function T(t){return q(t,function(t,e,n,r){if("function"==typeof t&&!t.options)return function(e,o,i){return t(function(t){n.components[r]=t,i()})}})}function q(t,e){return Array.prototype.concat.apply([],t.map(function(t){return Object.keys(t.components).map(function(n){return e(t.components[n],t.instances[n]&&t.instances[n].child,t,n)})}))}function C(t){t&&window.sessionStorage.setItem(t,JSON.stringify({x:window.pageXOffset,y:window.pageYOffset}))}function I(t){if(t)return JSON.parse(window.sessionStorage.getItem(t))}function P(t){var e=document.documentElement.getBoundingClientRect(),n=t.getBoundingClientRect();return{x:n.left-e.left,y:n.top-e.top}}function L(t){return B(t.x)||B(t.y)}function V(t){return{x:B(t.x)?t.x:window.pageXOffset,y:B(t.y)?t.y:window.pageYOffset}}function B(t){return"number"==typeof t}function H(t){var e=window.location.pathname;return t&&0===e.indexOf(t)&&(e=e.slice(t.length)),e+window.location.search+window.location.hash}function U(t,e){var n=window.history;try{e?n.replaceState({key:ut},"",t):(ut=at(),n.pushState({key:ut},"",t)),C(ut)}catch(n){window.location[e?"assign":"replace"](t)}}function z(t){U(t,!0)}function M(){var t=F();return"/"===t.charAt(0)||(N("/"+t),!1)}function F(){var t=window.location.href,e=t.indexOf("#");return e===-1?"":t.slice(e+1)}function J(t){window.location.hash=t}function N(t){var e=window.location.href.indexOf("#");window.location.replace(window.location.href.slice(0,e>=0?e:0)+"#"+t)}var D={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,e){var n=e.props,r=e.children,o=e.parent,i=e.data;i.routerView=!0;for(var a=o.$route,u=o._routerViewCache||(o._routerViewCache={}),c=0,s=!1;o;)o.$vnode&&o.$vnode.data.routerView&&c++,o._inactive&&(s=!0),o=o.$parent;i.routerViewDepth=c;var p=a.matched[c];if(!p)return t();var f=s?u[n.name]:u[n.name]=p.components[n.name],h=t(f,i,r);return s||(p.instances[n.name]=h),h}},X=encodeURIComponent,Y=decodeURIComponent,W={name:"router-link",props:{to:{type:[String,Object],required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String},render:function(t){var e=this,o=this.$router,a=this.$route,u=h(this.to,a,this.append),c=o.match(u),s=c.redirectedFrom||c.fullPath,p=o.history.base,f=p?n(p+s):s,d={},y=this.activeClass||o.options.linkActiveClass||"router-link-active";d[y]=this.exact?r(a,c):i(a,c);var v={class:d,on:{click:function(t){t.preventDefault(),e.replace?o.replace(u):o.push(u)}}};if("a"===this.tag)v.attrs={href:f};else{var m=l(this.$slots.default);if(m){var g=m.data||(m.data={}),w=g.attrs||(g.attrs={});w.href=f}}return t(this.tag,v,this.$slots.default)}},G=v(function(t){t.exports=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)}}),K=y(G),Q=Object.freeze({default:K}),Z=v(function(t){function e(t){for(var e,n=[],r=0,o=0,i="";null!=(e=m.exec(t));){var a=e[0],c=e[1],s=e.index;if(i+=t.slice(o,s),o=s+a.length,c)i+=c[1];else{var p=t[o],f=e[2],h=e[3],l=e[4],d=e[5],y=e[6],v=e[7];i&&(n.push(i),i="");var g=null!=f&&null!=p&&p!==f,w="+"===y||"*"===y,b="?"===y||"*"===y,x=e[2]||"/",k=l||d||(v?".*":"[^"+x+"]+?");n.push({name:h||r++,prefix:f||"",delimiter:x,optional:b,repeat:w,partial:g,asterisk:!!v,pattern:u(k)})}}return o<t.length&&(i+=t.substr(o)),i&&n.push(i),n}function n(t){return i(e(t))}function r(t){return encodeURI(t).replace(/[\/?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function o(t){return encodeURI(t).replace(/[?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function i(t){for(var e=new Array(t.length),n=0;n<t.length;n++)"object"==typeof t[n]&&(e[n]=new RegExp("^(?:"+t[n].pattern+")$"));return function(n,i){for(var a="",u=n||{},c=i||{},s=c.pretty?r:encodeURIComponent,p=0;p<t.length;p++){var f=t[p];if("string"!=typeof f){var h,l=u[f.name];if(null==l){if(f.optional){f.partial&&(a+=f.prefix);continue}throw new TypeError('Expected "'+f.name+'" to be defined')}if(v(l)){if(!f.repeat)throw new TypeError('Expected "'+f.name+'" to not repeat, but received `'+JSON.stringify(l)+"`");if(0===l.length){if(f.optional)continue;throw new TypeError('Expected "'+f.name+'" to not be empty')}for(var d=0;d<l.length;d++){if(h=s(l[d]),!e[p].test(h))throw new TypeError('Expected all "'+f.name+'" to match "'+f.pattern+'", but received `'+JSON.stringify(h)+"`");a+=(0===d?f.prefix:f.delimiter)+h}}else{if(h=f.asterisk?o(l):s(l),!e[p].test(h))throw new TypeError('Expected "'+f.name+'" to match "'+f.pattern+'", but received "'+h+'"');a+=f.prefix+h}}else a+=f}return a}}function a(t){return t.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function u(t){return t.replace(/([=!:$\/()])/g,"\\$1")}function c(t,e){return t.keys=e,t}function s(t){return t.sensitive?"":"i"}function p(t,e){var n=t.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)e.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return c(t,e)}function f(t,e,n){for(var r=[],o=0;o<t.length;o++)r.push(d(t[o],e,n).source);var i=new RegExp("(?:"+r.join("|")+")",s(n));return c(i,e)}function h(t,n,r){for(var o=e(t),i=l(o,r),a=0;a<o.length;a++)"string"!=typeof o[a]&&n.push(o[a]);return c(i,n)}function l(t,e){e=e||{};for(var n=e.strict,r=e.end!==!1,o="",i=t[t.length-1],u="string"==typeof i&&/\/$/.test(i),c=0;c<t.length;c++){var p=t[c];if("string"==typeof p)o+=a(p);else{var f=a(p.prefix),h="(?:"+p.pattern+")";p.repeat&&(h+="(?:"+f+h+")*"),h=p.optional?p.partial?f+"("+h+")?":"(?:"+f+"("+h+"))?":f+"("+h+")",o+=h}}return n||(o=(u?o.slice(0,-2):o)+"(?:\\/(?=$))?"),o+=r?"$":n&&u?"":"(?=\\/|$)",new RegExp("^"+o,s(e))}function d(t,e,n){return e=e||[],v(e)?n||(n={}):(n=e,e=[]),t instanceof RegExp?p(t,e):v(t)?f(t,e,n):h(t,e,n)}var v=y(Q);t.exports=d,t.exports.parse=e,t.exports.compile=n,t.exports.tokensToFunction=i,t.exports.tokensToRegExp=l;var m=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g")}),tt=y(Z),et=Object.create(null),nt=Object.create(null),rt="undefined"!=typeof window,ot=rt&&function(){var t=window.navigator.userAgent;return(t.indexOf("Android 2.")===-1&&t.indexOf("Android 4.0")===-1||t.indexOf("Mobile Safari")===-1||t.indexOf("Chrome")!==-1||t.indexOf("Windows Phone")!==-1)&&(window.history&&"pushState"in window.history)}(),it=function(t,e){var n=this;this.router=t,this.base=S(e),this.current=x(null,{path:"__vue_router_init__"}),this.pending=null,this.transitionTo(this.getLocation(),function(t){n.onInit(t)})};it.prototype.listen=function(t){this.cb=t},it.prototype.transitionTo=function(t,e){var n=this,r=this.router.match(t,this.current);this.confirmTransition(r,function(){n.updateRoute(r),e&&e(r)})},it.prototype.confirmTransition=function(t,e){var n=this;if(!r(t,this.current)){var o=$(this.current.matched,t.matched),i=o.deactivated,a=o.activated,u=[].concat(R(i),this.router.beforeHooks,a.map(function(t){return t.beforeEnter}),T(a)).filter(function(t){return t});this.pending=t;var c=function(t){return n.push(t)};A(u,function(e,n){e(t,c,n)},function(){r(t,n.pending)&&(n.pending=null,e(t))})}},it.prototype.updateRoute=function(t){this.current=t,this.cb&&this.cb(t),this.router.afterHooks.forEach(function(e){e&&e(t)})},it.prototype.getLocation=function(){return"/"};var at=function(){return String(Date.now())},ut=at(),ct=function(t){function e(e,n){var r=this;t.call(this,e,n);var o=e.options.scrollBehavior;window.addEventListener("popstate",function(t){ut=t.state&&t.state.key;var e=r.current;r.transitionTo(r.getLocation(),function(t){o&&r.handleScroll(t,e,!0)})}),o&&window.addEventListener("scroll",function(){C(ut)})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onInit=function(){var t=n(this.base+this.current.fullPath);this.getLocation()!==t&&z(t)},e.prototype.go=function(t){window.history.go(t)},e.prototype.push=function(e){var r=this,o=this.current;t.prototype.transitionTo.call(this,e,function(t){U(n(r.base+t.fullPath)),r.handleScroll(t,o,!1)})},e.prototype.replace=function(e){var r=this,o=this.current;t.prototype.transitionTo.call(this,e,function(t){z(n(r.base+t.fullPath)),r.handleScroll(t,o,!1)})},e.prototype.getLocation=function(){return H(this.base)},e.prototype.handleScroll=function(t,e,n){var r=this.router;if(r.app){var o=r.options.scrollBehavior;o&&(u("function"==typeof o,"scrollBehavior must be a function"),r.app.$nextTick(function(){var r=I(ut),i=o(t,e,n?r:null);if(i){var a="object"==typeof i;if(a&&i.selector){var u=document.querySelector(i.selector);u?r=P(u):L(i)&&(r=V(i))}else a&&L(i)&&(r=V(i));r&&window.scrollTo(r.x,r.y)}}))}},e}(it),st=function(t){function e(e,n,r){var o=this;t.call(this,e,n),r&&this.checkFallback()||window.addEventListener("hashchange",function(){o.onHashChange()})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onInit=function(){M(),F()!==this.current.fullPath&&N(this.current.fullPath)},e.prototype.checkFallback=function(){var t=H(this.base);if(!/^\/#/.test(t))return window.location.replace(n(this.base+"/#"+t)),!0},e.prototype.onHashChange=function(){M()&&this.transitionTo(this.getLocation(),function(t){N(t.fullPath)})},e.prototype.push=function(e){t.prototype.transitionTo.call(this,e,function(t){J(t.fullPath)})},e.prototype.replace=function(e){t.prototype.transitionTo.call(this,e,function(t){N(t.fullPath)})},e.prototype.go=function(t){window.history.go(t)},e.prototype.getLocation=function(){return F()},e}(it),pt=function(t){function e(e){t.call(this,e),this.stack=[],this.index=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onInit=function(){this.stack=[this.current]},e.prototype.push=function(e){var n=this;t.prototype.transitionTo.call(this,e,function(t){n.stack=n.stack.slice(0,n.index+1).concat(t),n.index++})},e.prototype.replace=function(e){var n=this;t.prototype.transitionTo.call(this,e,function(t){n.stack=n.stack.slice(0,n.index).concat(t)})},e.prototype.go=function(t){var e=this,n=this.index+t;if(!this.stack,!(n<0||n>=this.stack.length)){var r=this.stack[n];this.confirmTransition(r,function(){e.index=n,e.updateRoute(r)})}},e.prototype.setInitialRoute=function(t){this.current=t,this.stack=[this.current],this.index=0},e}(it),ft=function(t){void 0===t&&(t={}),this.app=null,this.options=t,this.beforeHooks=[],this.afterHooks=[],this.match=b(t.routes||[]);var e=t.mode||"hash";this.fallback="history"===e&&!ot,this.fallback&&(e="hash"),rt||(e="abstract"),this.mode=e};return ft.prototype.init=function(t){var e=this;u(d.installed,"not installed. Make sure to call `Vue.use(VueRouter)` before creating root instance.");var n=this,r=n.mode,o=n.options,i=n.fallback;switch(r){case"history":this.history=new ct(this,o.base);break;case"hash":this.history=new st(this,o.base,i);break;case"abstract":this.history=new pt(this);break;default:u(!1,"invalid mode: "+r)}this.app=t,this.history.listen(function(t){e.app._route=t})},ft.prototype.beforeEach=function(t){this.beforeHooks.push(t)},ft.prototype.afterEach=function(t){this.afterHooks.push(t)},ft.prototype.push=function(t){this.history.push(t)},ft.prototype.replace=function(t){this.history.replace(t)},ft.prototype.go=function(t){this.history.go(t)},ft.prototype.back=function(){this.go(-1)},ft.prototype.forward=function(){this.go(1)},ft.prototype.setInitialLocation=function(t){this.history instanceof pt&&this.history.setInitialRoute(this.match(t))},ft.install=d,rt&&window.Vue&&window.Vue.use(ft),ft});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueRouter=e()}(this,function(){"use strict";function t(t,e,n){if("/"===t.charAt(0))return t;if("?"===t.charAt(0)||"#"===t.charAt(0))return e+t;var r=e.split("/");n&&r[r.length-1]||r.pop();for(var o=t.replace(/^\//,"").split("/"),i=0;i<o.length;i++){var a=o[i];"."!==a&&(".."===a?r.pop():r.push(a))}return""!==r[0]&&r.unshift(""),r.join("/")}function e(t){var e="",n="",r=t.indexOf("#");r>=0&&(e=t.slice(r),t=t.slice(0,r));var o=t.indexOf("?");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{path:t,query:n,hash:e}}function n(t){return t.replace(/\/\//g,"/")}function r(t,e){return!!e&&(t.path&&e.path?t.path===e.path&&t.hash===e.hash&&o(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&o(t.query,e.query)&&o(t.params,e.params)))}function o(t,e){void 0===t&&(t={}),void 0===e&&(e={});var n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(function(n){return String(t[n])===String(e[n])})}function i(t,e){return 0===t.path.indexOf(e.path)&&(!e.hash||t.hash===e.hash)&&a(t.query,e.query)}function a(t,e){for(var n in e)if(!(n in t))return!1;return!0}function u(t,e){if(!t)throw new Error("[vue-router] "+e)}function c(t,e){t||"undefined"!=typeof console&&console.warn("[vue-router] "+e)}function s(t,e){if(void 0===e&&(e={}),t){var n;try{n=p(t)}catch(t){c(!1,t.message),n={}}for(var r in e)n[r]=e[r];return n}return e}function p(t){var e=Object.create(null);return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(function(t){var n=t.replace(/\+/g," ").split("="),r=Y(n.shift()),o=n.length>0?Y(n.join("=")):null;void 0===e[r]?e[r]=o:Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]}),e):e}function f(t){var e=t?Object.keys(t).sort().map(function(e){var n=t[e];if(void 0===n)return"";if(null===n)return X(e);if(Array.isArray(n)){var r=[];return n.slice().forEach(function(t){void 0!==t&&(null===t?r.push(X(e)):r.push(X(e)+"="+X(t)))}),r.join("&")}return X(e)+"="+X(n)}).filter(function(t){return t.length>0}).join("&"):null;return e?"?"+e:""}function h(n,r,o){var i="string"==typeof n?{path:n}:n;if(i.name||i._normalized)return i;var a=e(i.path||""),u=r&&r.path||"/",c=a.path?t(a.path,u,o):r&&r.path||"/",p=s(a.query,i.query),f=i.hash||a.hash;return f&&"#"!==f.charAt(0)&&(f="#"+f),{_normalized:!0,path:c,query:p,hash:f}}function l(t){if(t)for(var e,n=0;n<t.length;n++){if(e=t[n],"a"===e.tag)return e;if(e.children&&(e=l(e.children)))return e}}function d(t){d.installed||(d.installed=!0,Object.defineProperty(t.prototype,"$router",{get:function(){return this.$root._router}}),Object.defineProperty(t.prototype,"$route",{get:function(){return this.$root._route}}),t.mixin({beforeCreate:function(){this.$options.router&&(this._router=this.$options.router,this._router.init(this),t.util.defineReactive(this,"_route",this._router.history.current))}}),t.component("router-view",D),t.component("router-link",W))}function y(t){return t&&"object"==typeof t&&"default"in t?t.default:t}function v(t,e){return e={exports:{}},t(e,e.exports),e.exports}function m(t){var e=Object.create(null),n=Object.create(null);return t.forEach(function(t){g(e,n,t)}),{pathMap:e,nameMap:n}}function g(t,e,n,r,o){var i=n.path,a=n.name;u(null!=i,'"path" is required in a route configuration.');var c={path:w(i,r),components:n.components||{default:n.component},instances:{},name:a,parent:r,matchAs:o,redirect:n.redirect,beforeEnter:n.beforeEnter,meta:n.meta||{}};n.children&&n.children.forEach(function(n){g(t,e,n,c)}),n.alias&&(Array.isArray(n.alias)?n.alias.forEach(function(n){g(t,e,{path:n},r,c.path)}):g(t,e,{path:n.alias},r,c.path)),t[c.path]=c,a&&(e[a]=c)}function w(t,e){return t=t.replace(/\/$/,""),"/"===t[0]?t:null==e?t:n(e.path+"/"+t)}function b(t){function e(t,e,n){var r=h(t,e),i=r.name;if(i){var u=s[i];if(u)return r.path=O(u.path,r.params,'named route "'+i+'"'),o(u,r,n)}else if(r.path){r.params={};for(var c in a)if(k(c,r.params,r.path))return o(a[c],r,n)}return o(null,r)}function n(t,n){var r=n.query,i=n.hash,a=n.params,p=t.redirect,f=p&&"object"==typeof p&&p.name;if(f){var h=s[f];return u(h,'redirect failed: named route "'+f+'" not found.'),e({_normalized:!0,name:f,query:r,hash:i,params:a},void 0,n)}if("string"==typeof p){var l=E(p,t),d=O(l,a,'redirect route with path "'+l+'"');return e({_normalized:!0,path:d,query:r,hash:i},void 0,n)}return c(!1,"invalid redirect option: "+JSON.stringify(p)),o(null,n)}function r(t,n,r){var i=O(r,n.params,'aliased route with path "'+r+'"'),a=e({_normalized:!0,path:i});if(a){var u=a.matched,c=u[u.length-1];return n.params=a.params,o(c,n)}return o(null,n)}function o(t,e,o){return t&&t.redirect?n(t,o||e):t&&t.matchAs?r(t,e,t.matchAs):x(t,e,o)}var i=m(t),a=i.pathMap,s=i.nameMap;return e}function x(t,e,n){var r={name:e.name,path:e.path||"/",hash:e.hash||"",query:e.query||{},params:e.params||{},fullPath:j(e),matched:t?_(t):[]};return n&&(r.redirectedFrom=j(n)),Object.freeze(r)}function k(t,e,n){var r,o,i=et[t];i?(r=i.keys,o=i.regexp):(r=[],o=tt(t,r),et[t]={keys:r,regexp:o});var a=n.match(o);if(!a)return!1;if(!e)return!0;for(var u=1,c=a.length;u<c;++u){var s=r[u-1],p="string"==typeof a[u]?decodeURIComponent(a[u]):a[u];s&&(e[s.name]=p)}return!0}function O(t,e,n){try{var r=nt[t]||(nt[t]=tt.compile(t));return r(e||{},{pretty:!0})}catch(t){return u(!1,"missing param for "+n+": "+t.message),""}}function _(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function E(e,n){return t(e,n.parent?n.parent.path:"/",!0)}function j(t){var e=t.path,n=t.query;void 0===n&&(n={});var r=t.hash;return void 0===r&&(r=""),(e||"/")+f(n)+r}function A(t,e,n){var r=function(o){o>=t.length?n():e(t[o],function(){r(o+1)})};r(0)}function S(t){if(!t)if(rt){var e=document.querySelector("base");t=e?e.getAttribute("href"):"/"}else t="/";return"/"!==t.charAt(0)&&(t="/"+t),t.replace(/\/$/,"")}function $(t,e){var n,r=Math.max(t.length,e.length);for(n=0;n<r&&t[n]===e[n];n++);return{activated:e.slice(n),deactivated:t.slice(n)}}function R(t){return q(t,function(t,e){var n=t&&t.beforeRouteLeave;if(n)return function(){return n.apply(e,arguments)}}).reverse()}function T(t){return q(t,function(t,e,n,r){if("function"==typeof t&&!t.options)return function(e,o,i){return t(function(t){n.components[r]=t,i()})}})}function q(t,e){return Array.prototype.concat.apply([],t.map(function(t){return Object.keys(t.components).map(function(n){return e(t.components[n],t.instances[n]&&t.instances[n].child,t,n)})}))}function C(t){t&&window.sessionStorage.setItem(t,JSON.stringify({x:window.pageXOffset,y:window.pageYOffset}))}function I(t){if(t)return JSON.parse(window.sessionStorage.getItem(t))}function P(t){var e=document.documentElement.getBoundingClientRect(),n=t.getBoundingClientRect();return{x:n.left-e.left,y:n.top-e.top}}function L(t){return B(t.x)||B(t.y)}function V(t){return{x:B(t.x)?t.x:window.pageXOffset,y:B(t.y)?t.y:window.pageYOffset}}function B(t){return"number"==typeof t}function H(t){var e=window.location.pathname;return t&&0===e.indexOf(t)&&(e=e.slice(t.length)),(e||"/")+window.location.search+window.location.hash}function U(t,e){var n=window.history;try{e?n.replaceState({key:ut},"",t):(ut=at(),n.pushState({key:ut},"",t)),C(ut)}catch(n){window.location[e?"assign":"replace"](t)}}function z(t){U(t,!0)}function M(){var t=F();return"/"===t.charAt(0)||(N("/"+t),!1)}function F(){var t=window.location.href,e=t.indexOf("#");return e===-1?"":t.slice(e+1)}function J(t){window.location.hash=t}function N(t){var e=window.location.href.indexOf("#");window.location.replace(window.location.href.slice(0,e>=0?e:0)+"#"+t)}var D={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,e){var n=e.props,r=e.children,o=e.parent,i=e.data;i.routerView=!0;for(var a=o.$route,u=o._routerViewCache||(o._routerViewCache={}),c=0,s=!1;o;)o.$vnode&&o.$vnode.data.routerView&&c++,o._inactive&&(s=!0),o=o.$parent;i.routerViewDepth=c;var p=a.matched[c];if(!p)return t();var f=s?u[n.name]:u[n.name]=p.components[n.name],h=t(f,i,r);return s||(p.instances[n.name]=h),h}},X=encodeURIComponent,Y=decodeURIComponent,W={name:"router-link",props:{to:{type:[String,Object],required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String},render:function(t){var e=this,o=this.$router,a=this.$route,u=h(this.to,a,this.append),c=o.match(u),s=c.redirectedFrom||c.fullPath,p=o.history.base,f=p?n(p+s):s,d={},y=this.activeClass||o.options.linkActiveClass||"router-link-active";d[y]=this.exact?r(a,c):i(a,c);var v={class:d,on:{click:function(t){t.preventDefault(),e.replace?o.replace(u):o.push(u)}}};if("a"===this.tag)v.attrs={href:f};else{var m=l(this.$slots.default);if(m){var g=m.data||(m.data={}),w=g.attrs||(g.attrs={});w.href=f}}return t(this.tag,v,this.$slots.default)}},G=v(function(t){t.exports=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)}}),K=y(G),Q=Object.freeze({default:K}),Z=v(function(t){function e(t){for(var e,n=[],r=0,o=0,i="";null!=(e=m.exec(t));){var a=e[0],c=e[1],s=e.index;if(i+=t.slice(o,s),o=s+a.length,c)i+=c[1];else{var p=t[o],f=e[2],h=e[3],l=e[4],d=e[5],y=e[6],v=e[7];i&&(n.push(i),i="");var g=null!=f&&null!=p&&p!==f,w="+"===y||"*"===y,b="?"===y||"*"===y,x=e[2]||"/",k=l||d||(v?".*":"[^"+x+"]+?");n.push({name:h||r++,prefix:f||"",delimiter:x,optional:b,repeat:w,partial:g,asterisk:!!v,pattern:u(k)})}}return o<t.length&&(i+=t.substr(o)),i&&n.push(i),n}function n(t){return i(e(t))}function r(t){return encodeURI(t).replace(/[\/?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function o(t){return encodeURI(t).replace(/[?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function i(t){for(var e=new Array(t.length),n=0;n<t.length;n++)"object"==typeof t[n]&&(e[n]=new RegExp("^(?:"+t[n].pattern+")$"));return function(n,i){for(var a="",u=n||{},c=i||{},s=c.pretty?r:encodeURIComponent,p=0;p<t.length;p++){var f=t[p];if("string"!=typeof f){var h,l=u[f.name];if(null==l){if(f.optional){f.partial&&(a+=f.prefix);continue}throw new TypeError('Expected "'+f.name+'" to be defined')}if(v(l)){if(!f.repeat)throw new TypeError('Expected "'+f.name+'" to not repeat, but received `'+JSON.stringify(l)+"`");if(0===l.length){if(f.optional)continue;throw new TypeError('Expected "'+f.name+'" to not be empty')}for(var d=0;d<l.length;d++){if(h=s(l[d]),!e[p].test(h))throw new TypeError('Expected all "'+f.name+'" to match "'+f.pattern+'", but received `'+JSON.stringify(h)+"`");a+=(0===d?f.prefix:f.delimiter)+h}}else{if(h=f.asterisk?o(l):s(l),!e[p].test(h))throw new TypeError('Expected "'+f.name+'" to match "'+f.pattern+'", but received "'+h+'"');a+=f.prefix+h}}else a+=f}return a}}function a(t){return t.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function u(t){return t.replace(/([=!:$\/()])/g,"\\$1")}function c(t,e){return t.keys=e,t}function s(t){return t.sensitive?"":"i"}function p(t,e){var n=t.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.length;r++)e.push({name:r,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return c(t,e)}function f(t,e,n){for(var r=[],o=0;o<t.length;o++)r.push(d(t[o],e,n).source);var i=new RegExp("(?:"+r.join("|")+")",s(n));return c(i,e)}function h(t,n,r){for(var o=e(t),i=l(o,r),a=0;a<o.length;a++)"string"!=typeof o[a]&&n.push(o[a]);return c(i,n)}function l(t,e){e=e||{};for(var n=e.strict,r=e.end!==!1,o="",i=t[t.length-1],u="string"==typeof i&&/\/$/.test(i),c=0;c<t.length;c++){var p=t[c];if("string"==typeof p)o+=a(p);else{var f=a(p.prefix),h="(?:"+p.pattern+")";p.repeat&&(h+="(?:"+f+h+")*"),h=p.optional?p.partial?f+"("+h+")?":"(?:"+f+"("+h+"))?":f+"("+h+")",o+=h}}return n||(o=(u?o.slice(0,-2):o)+"(?:\\/(?=$))?"),o+=r?"$":n&&u?"":"(?=\\/|$)",new RegExp("^"+o,s(e))}function d(t,e,n){return e=e||[],v(e)?n||(n={}):(n=e,e=[]),t instanceof RegExp?p(t,e):v(t)?f(t,e,n):h(t,e,n)}var v=y(Q);t.exports=d,t.exports.parse=e,t.exports.compile=n,t.exports.tokensToFunction=i,t.exports.tokensToRegExp=l;var m=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g")}),tt=y(Z),et=Object.create(null),nt=Object.create(null),rt="undefined"!=typeof window,ot=rt&&function(){var t=window.navigator.userAgent;return(t.indexOf("Android 2.")===-1&&t.indexOf("Android 4.0")===-1||t.indexOf("Mobile Safari")===-1||t.indexOf("Chrome")!==-1||t.indexOf("Windows Phone")!==-1)&&(window.history&&"pushState"in window.history)}(),it=function(t,e){var n=this;this.router=t,this.base=S(e),this.current=x(null,{path:"__vue_router_init__"}),this.pending=null,this.transitionTo(this.getLocation(),function(t){n.onInit(t)})};it.prototype.listen=function(t){this.cb=t},it.prototype.transitionTo=function(t,e){var n=this,r=this.router.match(t,this.current);this.confirmTransition(r,function(){n.updateRoute(r),e&&e(r)})},it.prototype.confirmTransition=function(t,e){var n=this;if(!r(t,this.current)){var o=$(this.current.matched,t.matched),i=o.deactivated,a=o.activated,u=[].concat(R(i),this.router.beforeHooks,a.map(function(t){return t.beforeEnter}),T(a)).filter(function(t){return t});this.pending=t;var c=function(t){return n.push(t)};A(u,function(e,n){e(t,c,n)},function(){r(t,n.pending)&&(n.pending=null,e(t))})}},it.prototype.updateRoute=function(t){this.current=t,this.cb&&this.cb(t),this.router.afterHooks.forEach(function(e){e&&e(t)})};var at=function(){return String(Date.now())},ut=at(),ct=function(t){function e(e,n){var r=this;t.call(this,e,n);var o=e.options.scrollBehavior;window.addEventListener("popstate",function(t){ut=t.state&&t.state.key;var e=r.current;r.transitionTo(r.getLocation(),function(t){o&&r.handleScroll(t,e,!0)})}),o&&window.addEventListener("scroll",function(){C(ut)})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onInit=function(){var t=n(this.base+this.current.fullPath);this.getLocation()!==t&&z(t)},e.prototype.go=function(t){window.history.go(t)},e.prototype.push=function(e){var r=this,o=this.current;t.prototype.transitionTo.call(this,e,function(t){U(n(r.base+t.fullPath)),r.handleScroll(t,o,!1)})},e.prototype.replace=function(e){var r=this,o=this.current;t.prototype.transitionTo.call(this,e,function(t){z(n(r.base+t.fullPath)),r.handleScroll(t,o,!1)})},e.prototype.getLocation=function(){return H(this.base)},e.prototype.handleScroll=function(t,e,n){var r=this.router;if(r.app){var o=r.options.scrollBehavior;o&&(u("function"==typeof o,"scrollBehavior must be a function"),r.app.$nextTick(function(){var r=I(ut),i=o(t,e,n?r:null);if(i){var a="object"==typeof i;if(a&&i.selector){var u=document.querySelector(i.selector);u?r=P(u):L(i)&&(r=V(i))}else a&&L(i)&&(r=V(i));r&&window.scrollTo(r.x,r.y)}}))}},e}(it),st=function(t){function e(e,n,r){var o=this;t.call(this,e,n),r&&this.checkFallback()||(M(),window.addEventListener("hashchange",function(){o.onHashChange()}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onInit=function(){F()!==this.current.fullPath&&N(this.current.fullPath)},e.prototype.checkFallback=function(){var t=H(this.base);if(!/^\/#/.test(t))return window.location.replace(n(this.base+"/#"+t)),!0},e.prototype.onHashChange=function(){M()&&this.transitionTo(this.getLocation(),function(t){N(t.fullPath)})},e.prototype.push=function(e){t.prototype.transitionTo.call(this,e,function(t){J(t.fullPath)})},e.prototype.replace=function(e){t.prototype.transitionTo.call(this,e,function(t){N(t.fullPath)})},e.prototype.go=function(t){window.history.go(t)},e.prototype.getLocation=function(){return F()},e}(it),pt=function(t){function e(e){t.call(this,e),this.stack=[],this.index=0}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.onInit=function(){this.stack=[this.current]},e.prototype.push=function(e){var n=this;t.prototype.transitionTo.call(this,e,function(t){n.stack=n.stack.slice(0,n.index+1).concat(t),n.index++})},e.prototype.replace=function(e){var n=this;t.prototype.transitionTo.call(this,e,function(t){n.stack=n.stack.slice(0,n.index).concat(t)})},e.prototype.go=function(t){var e=this,n=this.index+t;if(!this.stack,!(n<0||n>=this.stack.length)){var r=this.stack[n];this.confirmTransition(r,function(){e.index=n,e.updateRoute(r)})}},e.prototype.setInitialRoute=function(t){this.current=t,this.stack=[this.current],this.index=0},e}(it),ft=function(t){void 0===t&&(t={}),this.app=null,this.options=t,this.beforeHooks=[],this.afterHooks=[],this.match=b(t.routes||[]);var e=t.mode||"hash";this.fallback="history"===e&&!ot,this.fallback&&(e="hash"),rt||(e="abstract"),this.mode=e};return ft.prototype.init=function(t){var e=this;u(d.installed,"not installed. Make sure to call `Vue.use(VueRouter)` before creating root instance.");var n=this,r=n.mode,o=n.options,i=n.fallback;switch(r){case"history":this.history=new ct(this,o.base);break;case"hash":this.history=new st(this,o.base,i);break;case"abstract":this.history=new pt(this);break;default:u(!1,"invalid mode: "+r)}this.app=t,this.history.listen(function(t){e.app._route=t})},ft.prototype.beforeEach=function(t){this.beforeHooks.push(t)},ft.prototype.afterEach=function(t){this.afterHooks.push(t)},ft.prototype.push=function(t){this.history.push(t)},ft.prototype.replace=function(t){this.history.replace(t)},ft.prototype.go=function(t){this.history.go(t)},ft.prototype.back=function(){this.go(-1)},ft.prototype.forward=function(){this.go(1)},ft.prototype.setInitialLocation=function(t){this.history instanceof pt&&this.history.setInitialRoute(this.match(t))},ft.install=d,rt&&window.Vue&&window.Vue.use(ft),ft});
{
"name": "vue-router",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"description": "Official router for Vue.js 2.0",

@@ -5,0 +5,0 @@ "author": "Evan You",

@@ -14,13 +14,14 @@ /* @flow */

pending: ?Route;
cb: Function;
cb: (r: Route) => void;
// implemented by sub-classes
go: Function;
push: Function;
replace: Function;
onInit: Function;
go: (n: number) => void;
push: (loc: RawLocation) => void;
replace: (loc: RawLocation) => void;
onInit: (cb: Function) => void;
getLocation: () => string;
constructor (router: VueRouter, base: ?string) {
this.router = router
this.base = normalizeBae(base)
this.base = normalizeBase(base)
// start with a route object that stands for "nowhere"

@@ -91,9 +92,5 @@ this.current = createRoute(null, {

}
getLocation (): string {
return '/'
}
}
function normalizeBae (base: ?string): string {
function normalizeBase (base: ?string): string {
if (!base) {

@@ -100,0 +97,0 @@ if (inBrowser) {

@@ -15,2 +15,3 @@ /* @flow */

}
ensureSlash()
window.addEventListener('hashchange', () => {

@@ -22,3 +23,2 @@ this.onHashChange()

onInit () {
ensureSlash()
// possible redirect on start

@@ -25,0 +25,0 @@ if (getHash() !== this.current.fullPath) {

@@ -115,3 +115,3 @@ /* @flow */

}
return path + window.location.search + window.location.hash
return (path || '/') + window.location.search + window.location.hash
}

@@ -118,0 +118,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