Socket
Socket
Sign inDemoInstall

riot-route

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

riot-route - npm Package Compare versions

Comparing version 2.3.1-beta to 2.3.1

dist/es6.route.js

19

dist/amd.route.js

@@ -65,2 +65,6 @@ ;define(function(require, exports, module) {

function isString(str) {
return typeof str == 'string'
}
/**

@@ -156,3 +160,3 @@ * Get the part after domain name

prot.m = function(first, second) {
if (first[0] && (!second || second[0])) go(first, second)
if (isString(first) && (!second || isString(second))) go(first, second)
else if (second) this.r(first, second)

@@ -190,3 +194,6 @@ else this.r('@', first)

prot.r = function(filter, action) {
if (filter != '@') this.$.push(filter)
if (filter != '@') {
filter = '/' + normalize(filter)
this.$.push(filter)
}
this.on(filter, action)

@@ -259,4 +266,7 @@ }

/** Start routing **/
route.start = function () {
/**
* Start routing
* @param {boolean} autoExec - automatically exec after starting if true
*/
route.start = function (autoExec) {
if (!started) {

@@ -267,2 +277,3 @@ win[ADD_EVENT_LISTENER](POPSTATE, emit)

}
if (autoExec) emit(true)
}

@@ -269,0 +280,0 @@

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

define(function(t,e,n){"use strict";var i=t("riot-observable");var r=/^.+?\/+[^\/]+/,f="EventListener",o="remove"+f,s="add"+f,u="hasAttribute",a="replace",c="popstate",h="trigger",l=3,p=window,d=document,v=p.history.location||p.location,m=q.prototype,b=d&&d.ontouchstart?"touchstart":"click",g=false,w=i(),y,$,x,A,K=[],N=0;function E(t){return t.split(/[\/?#]/)}function k(t,e){var n=new RegExp("^"+e[a](/\*/g,"([^/?#]+?)")[a](/\.\./,".*")+"$"),i=t.match(n);if(i)return i.slice(1)}function q(){this.$=[];i(this);w.on("stop",this.s.bind(this));w.on("emit",this.e.bind(this))}function D(t){return t[a](/^\/|\/$/,"")}function L(t){return(t||v.href)[a](r,"")}function O(t){return y[0]=="#"?(t||v.href).split(y)[1]||"":L(t)[a](y,"")}function P(t){var e=N==0;if(l<=N)return;N++;K.push(function(){var e=O();if(t||e!=$){w[h]("emit",e);$=e}});if(e){while(K.length){K[0]();K.shift()}N=0}}function R(t){if(t.which!=1||t.metaKey||t.ctrlKey||t.shiftKey||t.defaultPrevented)return;var e=t.target;while(e&&e.nodeName!="A")e=e.parentNode;if(!e||e.nodeName!="A"||e[u]("download")||!e[u]("href")||e.target&&e.target!="_self"||e.href.indexOf(v.href.match(r)[0])==-1)return;if(e.href!=v.href){if(e.href.split("#")[0]==v.href.split("#")[0])return;S(O(e.href),e.title||d.title)}t.preventDefault()}function S(t,e){e=e||d.title;history.pushState(null,e,y+D(t));d.title=e;P()}m.m=function(t,e){if(t[0]&&(!e||e[0]))S(t,e);else if(e)this.r(t,e);else this.r("@",t)};m.s=function(){this.off("*");this.$=[]};m.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?x:A)(D(t),D(e));if(n){this[h].apply(null,[e].concat(n));return true}},this)};m.r=function(t,e){if(t!="@")this.$.push(t);this.on(t,e)};var _=new q;var j=_.m.bind(_);j.create=function(){var t=new q;t.m.stop=t.s.bind(t);return t.m.bind(t)};j.base=function(t){y=t||"#";$=O()};j.exec=function(){P(true)};j.parser=function(t,e){if(!t&&!e){x=E;A=k}if(t)x=t;if(e)A=e};j.query=function(){var t={};v.href[a](/[?&](.+?)=([^&]*)/g,function(e,n,i){t[n]=i});return t};j.stop=function(){if(g){p[o](c,P);d[o](b,R);w[h]("stop");g=false}};j.start=function(){if(!g){p[s](c,P);d[s](b,R);g=true}};j.base();j.parser();n.exports=j});
define(function(t,e,n){"use strict";var i=t("riot-observable");var r=/^.+?\/+[^\/]+/,f="EventListener",o="remove"+f,s="add"+f,u="hasAttribute",c="replace",a="popstate",h="trigger",l=3,p=window,d=document,v=p.history.location||p.location,m=q.prototype,b=d&&d.ontouchstart?"touchstart":"click",g=false,w=i(),y,$,x,A,K=[],N=0;function E(t){return t.split(/[\/?#]/)}function k(t,e){var n=new RegExp("^"+e[c](/\*/g,"([^/?#]+?)")[c](/\.\./,".*")+"$"),i=t.match(n);if(i)return i.slice(1)}function q(){this.$=[];i(this);w.on("stop",this.s.bind(this));w.on("emit",this.e.bind(this))}function D(t){return t[c](/^\/|\/$/,"")}function L(t){return typeof t=="string"}function O(t){return(t||v.href)[c](r,"")}function P(t){return y[0]=="#"?(t||v.href).split(y)[1]||"":O(t)[c](y,"")}function R(t){var e=N==0;if(l<=N)return;N++;K.push(function(){var e=P();if(t||e!=$){w[h]("emit",e);$=e}});if(e){while(K.length){K[0]();K.shift()}N=0}}function S(t){if(t.which!=1||t.metaKey||t.ctrlKey||t.shiftKey||t.defaultPrevented)return;var e=t.target;while(e&&e.nodeName!="A")e=e.parentNode;if(!e||e.nodeName!="A"||e[u]("download")||!e[u]("href")||e.target&&e.target!="_self"||e.href.indexOf(v.href.match(r)[0])==-1)return;if(e.href!=v.href){if(e.href.split("#")[0]==v.href.split("#")[0])return;_(P(e.href),e.title||d.title)}t.preventDefault()}function _(t,e){e=e||d.title;history.pushState(null,e,y+D(t));d.title=e;R()}m.m=function(t,e){if(L(t)&&(!e||L(e)))_(t,e);else if(e)this.r(t,e);else this.r("@",t)};m.s=function(){this.off("*");this.$=[]};m.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?x:A)(D(t),D(e));if(n){this[h].apply(null,[e].concat(n));return true}},this)};m.r=function(t,e){if(t!="@"){t="/"+D(t);this.$.push(t)}this.on(t,e)};var j=new q;var z=j.m.bind(j);z.create=function(){var t=new q;t.m.stop=t.s.bind(t);return t.m.bind(t)};z.base=function(t){y=t||"#";$=P()};z.exec=function(){R(true)};z.parser=function(t,e){if(!t&&!e){x=E;A=k}if(t)x=t;if(e)A=e};z.query=function(){var t={};v.href[c](/[?&](.+?)=([^&]*)/g,function(e,n,i){t[n]=i});return t};z.stop=function(){if(g){p[o](a,R);d[o](b,S);w[h]("stop");g=false}};z.start=function(t){if(!g){p[s](a,R);d[s](b,S);g=true}if(t)R(true)};z.base();z.parser();n.exports=z});

@@ -63,2 +63,6 @@ ;(function(riot) { if (!window) return;

function isString(str) {
return typeof str == 'string'
}
/**

@@ -154,3 +158,3 @@ * Get the part after domain name

prot.m = function(first, second) {
if (first[0] && (!second || second[0])) go(first, second)
if (isString(first) && (!second || isString(second))) go(first, second)
else if (second) this.r(first, second)

@@ -188,3 +192,6 @@ else this.r('@', first)

prot.r = function(filter, action) {
if (filter != '@') this.$.push(filter)
if (filter != '@') {
filter = '/' + normalize(filter)
this.$.push(filter)
}
this.on(filter, action)

@@ -257,4 +264,7 @@ }

/** Start routing **/
route.start = function () {
/**
* Start routing
* @param {boolean} autoExec - automatically exec after starting if true
*/
route.start = function (autoExec) {
if (!started) {

@@ -265,2 +275,3 @@ win[ADD_EVENT_LISTENER](POPSTATE, emit)

}
if (autoExec) emit(true)
}

@@ -267,0 +278,0 @@

@@ -186,2 +186,6 @@ ;(function() {

function isString(str) {
return typeof str == 'string'
}
/**

@@ -277,3 +281,3 @@ * Get the part after domain name

prot.m = function(first, second) {
if (first[0] && (!second || second[0])) go(first, second)
if (isString(first) && (!second || isString(second))) go(first, second)
else if (second) this.r(first, second)

@@ -311,3 +315,6 @@ else this.r('@', first)

prot.r = function(filter, action) {
if (filter != '@') this.$.push(filter)
if (filter != '@') {
filter = '/' + normalize(filter)
this.$.push(filter)
}
this.on(filter, action)

@@ -380,4 +387,7 @@ }

/** Start routing **/
route.start = function () {
/**
* Start routing
* @param {boolean} autoExec - automatically exec after starting if true
*/
route.start = function (autoExec) {
if (!started) {

@@ -388,2 +398,3 @@ win[ADD_EVENT_LISTENER](POPSTATE, emit)

}
if (autoExec) emit(true)
}

@@ -390,0 +401,0 @@

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

(function(){"use strict";var t=function(t){t=t||{};var e={},n=function(t,e){t.replace(/\S+/g,e)},r=function(e,n){Object.defineProperty(t,e,{value:n,enumerable:false,writable:false,configurable:false})};r("on",function(r,i){if(typeof i!="function")return t;n(r,function(t,n){(e[t]=e[t]||[]).push(i);i.typed=n>0});return t});r("off",function(r,i){if(r=="*")e={};else{n(r,function(t){if(i){var n=e[t];for(var r=0,f;f=n&&n[r];++r){if(f==i)n.splice(r--,1)}}else delete e[t]})}return t});r("one",function(e,n){function r(){t.off(e,r);n.apply(t,arguments)}return t.on(e,r)});r("trigger",function(r){var i=arguments.length-1,f=new Array(i);for(var o=0;o<i;o++){f[o]=arguments[o+1]}n(r,function(n){var r=(e[n]||[]).slice(0);for(var i=0,o;o=r[i];++i){if(o.busy)return;o.busy=1;try{o.apply(t,o.typed?[n].concat(f):f)}catch(u){}if(r[i]!==o){i--}o.busy=0}if(e.all&&n!="all")t.trigger.apply(t,["all",n].concat(f))});return t});return t};var e=/^.+?\/+[^\/]+/,n="EventListener",r="remove"+n,i="add"+n,f="hasAttribute",o="replace",u="popstate",a="trigger",c=3,s=window,l=document,h=s.history.location||s.location,p=N.prototype,v=l&&l.ontouchstart?"touchstart":"click",d=false,y=t(),g,m,b,w,$=[],A=0;function x(t){return t.split(/[\/?#]/)}function K(t,e){var n=new RegExp("^"+e[o](/\*/g,"([^/?#]+?)")[o](/\.\./,".*")+"$"),r=t.match(n);if(r)return r.slice(1)}function N(){this.$=[];t(this);y.on("stop",this.s.bind(this));y.on("emit",this.e.bind(this))}function E(t){return t[o](/^\/|\/$/,"")}function O(t){return(t||h.href)[o](e,"")}function P(t){return g[0]=="#"?(t||h.href).split(g)[1]||"":O(t)[o](g,"")}function S(t){var e=A==0;if(c<=A)return;A++;$.push(function(){var e=P();if(t||e!=m){y[a]("emit",e);m=e}});if(e){while($.length){$[0]();$.shift()}A=0}}function j(t){if(t.which!=1||t.metaKey||t.ctrlKey||t.shiftKey||t.defaultPrevented)return;var n=t.target;while(n&&n.nodeName!="A")n=n.parentNode;if(!n||n.nodeName!="A"||n[f]("download")||!n[f]("href")||n.target&&n.target!="_self"||n.href.indexOf(h.href.match(e)[0])==-1)return;if(n.href!=h.href){if(n.href.split("#")[0]==h.href.split("#")[0])return;k(P(n.href),n.title||l.title)}t.preventDefault()}function k(t,e){e=e||l.title;history.pushState(null,e,g+E(t));l.title=e;S()}p.m=function(t,e){if(t[0]&&(!e||e[0]))k(t,e);else if(e)this.r(t,e);else this.r("@",t)};p.s=function(){this.off("*");this.$=[]};p.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?b:w)(E(t),E(e));if(n){this[a].apply(null,[e].concat(n));return true}},this)};p.r=function(t,e){if(t!="@")this.$.push(t);this.on(t,e)};var q=new N;var D=q.m.bind(q);D.create=function(){var t=new N;t.m.stop=t.s.bind(t);return t.m.bind(t)};D.base=function(t){g=t||"#";m=P()};D.exec=function(){S(true)};D.parser=function(t,e){if(!t&&!e){b=x;w=K}if(t)b=t;if(e)w=e};D.query=function(){var t={};h.href[o](/[?&](.+?)=([^&]*)/g,function(e,n,r){t[n]=r});return t};D.stop=function(){if(d){s[r](u,S);l[r](v,j);y[a]("stop");d=false}};D.start=function(){if(!d){s[i](u,S);l[i](v,j);d=true}};D.base();D.parser();window.route=D})();
(function(){"use strict";var t=function(t){t=t||{};var e={},n=function(t,e){t.replace(/\S+/g,e)},r=function(e,n){Object.defineProperty(t,e,{value:n,enumerable:false,writable:false,configurable:false})};r("on",function(r,i){if(typeof i!="function")return t;n(r,function(t,n){(e[t]=e[t]||[]).push(i);i.typed=n>0});return t});r("off",function(r,i){if(r=="*")e={};else{n(r,function(t){if(i){var n=e[t];for(var r=0,f;f=n&&n[r];++r){if(f==i)n.splice(r--,1)}}else delete e[t]})}return t});r("one",function(e,n){function r(){t.off(e,r);n.apply(t,arguments)}return t.on(e,r)});r("trigger",function(r){var i=arguments.length-1,f=new Array(i);for(var u=0;u<i;u++){f[u]=arguments[u+1]}n(r,function(n){var r=(e[n]||[]).slice(0);for(var i=0,u;u=r[i];++i){if(u.busy)return;u.busy=1;try{u.apply(t,u.typed?[n].concat(f):f)}catch(o){}if(r[i]!==u){i--}u.busy=0}if(e.all&&n!="all")t.trigger.apply(t,["all",n].concat(f))});return t});return t};var e=/^.+?\/+[^\/]+/,n="EventListener",r="remove"+n,i="add"+n,f="hasAttribute",u="replace",o="popstate",a="trigger",c=3,s=window,l=document,h=s.history.location||s.location,p=N.prototype,v=l&&l.ontouchstart?"touchstart":"click",d=false,y=t(),g,m,b,w,$=[],A=0;function x(t){return t.split(/[\/?#]/)}function K(t,e){var n=new RegExp("^"+e[u](/\*/g,"([^/?#]+?)")[u](/\.\./,".*")+"$"),r=t.match(n);if(r)return r.slice(1)}function N(){this.$=[];t(this);y.on("stop",this.s.bind(this));y.on("emit",this.e.bind(this))}function E(t){return t[u](/^\/|\/$/,"")}function O(t){return typeof t=="string"}function P(t){return(t||h.href)[u](e,"")}function S(t){return g[0]=="#"?(t||h.href).split(g)[1]||"":P(t)[u](g,"")}function j(t){var e=A==0;if(c<=A)return;A++;$.push(function(){var e=S();if(t||e!=m){y[a]("emit",e);m=e}});if(e){while($.length){$[0]();$.shift()}A=0}}function k(t){if(t.which!=1||t.metaKey||t.ctrlKey||t.shiftKey||t.defaultPrevented)return;var n=t.target;while(n&&n.nodeName!="A")n=n.parentNode;if(!n||n.nodeName!="A"||n[f]("download")||!n[f]("href")||n.target&&n.target!="_self"||n.href.indexOf(h.href.match(e)[0])==-1)return;if(n.href!=h.href){if(n.href.split("#")[0]==h.href.split("#")[0])return;q(S(n.href),n.title||l.title)}t.preventDefault()}function q(t,e){e=e||l.title;history.pushState(null,e,g+E(t));l.title=e;j()}p.m=function(t,e){if(O(t)&&(!e||O(e)))q(t,e);else if(e)this.r(t,e);else this.r("@",t)};p.s=function(){this.off("*");this.$=[]};p.e=function(t){this.$.concat("@").some(function(e){var n=(e=="@"?b:w)(E(t),E(e));if(n){this[a].apply(null,[e].concat(n));return true}},this)};p.r=function(t,e){if(t!="@"){t="/"+E(t);this.$.push(t)}this.on(t,e)};var D=new N;var L=D.m.bind(D);L.create=function(){var t=new N;t.m.stop=t.s.bind(t);return t.m.bind(t)};L.base=function(t){g=t||"#";m=S()};L.exec=function(){j(true)};L.parser=function(t,e){if(!t&&!e){b=x;w=K}if(t)b=t;if(e)w=e};L.query=function(){var t={};h.href[u](/[?&](.+?)=([^&]*)/g,function(e,n,r){t[n]=r});return t};L.stop=function(){if(d){s[r](o,j);l[r](v,k);y[a]("stop");d=false}};L.start=function(t){if(!d){s[i](o,j);l[i](v,k);d=true}if(t)j(true)};L.base();L.parser();window.route=L})();

@@ -137,2 +137,17 @@ # Router API

### route.start(autoExec)
Start listening the url changes and also exec routing on the current url.
```js
route.start(true)
```
This is a shorthand for:
```js
route.start()
route.exec()
```
### route.stop()

@@ -139,0 +154,0 @@

@@ -62,2 +62,6 @@ /**

function isString(str) {
return typeof str == 'string'
}
/**

@@ -153,3 +157,3 @@ * Get the part after domain name

prot.m = function(first, second) {
if (first[0] && (!second || second[0])) go(first, second)
if (isString(first) && (!second || isString(second))) go(first, second)
else if (second) this.r(first, second)

@@ -187,3 +191,6 @@ else this.r('@', first)

prot.r = function(filter, action) {
if (filter != '@') this.$.push(filter)
if (filter != '@') {
filter = '/' + normalize(filter)
this.$.push(filter)
}
this.on(filter, action)

@@ -256,4 +263,7 @@ }

/** Start routing **/
route.start = function () {
/**
* Start routing
* @param {boolean} autoExec - automatically exec after starting if true
*/
route.start = function (autoExec) {
if (!started) {

@@ -264,2 +274,3 @@ win[ADD_EVENT_LISTENER](POPSTATE, emit)

}
if (autoExec) emit(true)
}

@@ -266,0 +277,0 @@

{
"name": "riot-route",
"version": "2.3.1-beta",
"version": "2.3.1",
"description": "Simple client-side router",

@@ -24,3 +24,3 @@ "main": "lib/index.js",

"dependencies": {
"riot-observable": "^2.3.1-beta"
"riot-observable": "^2.3.1"
},

@@ -30,5 +30,5 @@ "devDependencies": {

"coveralls": "^2.11.4",
"eslint": "^1.8.0",
"eslint": "^1.9.0",
"expect.js": "^0.3.1",
"karma": "^0.13.14",
"karma": "^0.13.15",
"karma-coverage": "^0.5.3",

@@ -35,0 +35,0 @@ "karma-mocha": "^0.2.0",

@@ -235,2 +235,12 @@ function fireEvent(node, eventName) {

it('start with autoExec option', function() {
route.base('/')
route(function() {
counter++
})
var autoExec = true
route.start(autoExec)
expect(counter).to.be(1)
})
it('sets routings in weird order', function() {

@@ -368,2 +378,14 @@ route.base('/')

it('sets routing for root', function() {
route.base('/')
route('', function() {
counter++
})
route('other')
route('/')
route('other')
route('')
expect(counter).to.be(2)
})
it('redirecting inside the router', function() {

@@ -370,0 +392,0 @@ var str

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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