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.4.0 to 2.5.0

45

dist/amd.route.js

@@ -121,3 +121,3 @@ ;define(function(require, exports, module) {

// the stack is needed for redirections
var isRoot = emitStackLevel == 0
var isRoot = emitStackLevel == 0, first
if (MAX_EMIT_STACK_LEVEL <= emitStackLevel) return

@@ -134,6 +134,3 @@

if (isRoot) {
while (emitStack.length) {
emitStack[0]()
emitStack.shift()
}
while (first = emitStack.shift()) first() // stack increses within this call
emitStackLevel = 0

@@ -161,9 +158,9 @@ }

if (el.href != loc.href) {
if (
if (el.href != loc.href
&& (
el.href.split('#')[0] == loc.href.split('#')[0] // internal jump
|| base != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] == '#' && el.href.split(base)[0] != loc.href.split(base)[0] // outside of #base
|| !go(getPathFromBase(el.href), el.title || doc.title) // route not found
) return
}
)) return

@@ -181,18 +178,16 @@ e.preventDefault()

function go(path, title, shouldReplace) {
if (hist) { // if a browser
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
if (!hist) return central[TRIGGER]('emit', getPathFromBase(path))
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}

@@ -199,0 +194,0 @@

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

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

@@ -118,3 +118,3 @@ import observable from 'riot-observable'

// the stack is needed for redirections
var isRoot = emitStackLevel == 0
var isRoot = emitStackLevel == 0, first
if (MAX_EMIT_STACK_LEVEL <= emitStackLevel) return

@@ -131,6 +131,3 @@

if (isRoot) {
while (emitStack.length) {
emitStack[0]()
emitStack.shift()
}
while (first = emitStack.shift()) first() // stack increses within this call
emitStackLevel = 0

@@ -158,9 +155,9 @@ }

if (el.href != loc.href) {
if (
if (el.href != loc.href
&& (
el.href.split('#')[0] == loc.href.split('#')[0] // internal jump
|| base != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] == '#' && el.href.split(base)[0] != loc.href.split(base)[0] // outside of #base
|| !go(getPathFromBase(el.href), el.title || doc.title) // route not found
) return
}
)) return

@@ -178,18 +175,16 @@ e.preventDefault()

function go(path, title, shouldReplace) {
if (hist) { // if a browser
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
if (!hist) return central[TRIGGER]('emit', getPathFromBase(path))
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}

@@ -196,0 +191,0 @@

@@ -119,3 +119,3 @@ ;(function(riot) {

// the stack is needed for redirections
var isRoot = emitStackLevel == 0
var isRoot = emitStackLevel == 0, first
if (MAX_EMIT_STACK_LEVEL <= emitStackLevel) return

@@ -132,6 +132,3 @@

if (isRoot) {
while (emitStack.length) {
emitStack[0]()
emitStack.shift()
}
while (first = emitStack.shift()) first() // stack increses within this call
emitStackLevel = 0

@@ -159,9 +156,9 @@ }

if (el.href != loc.href) {
if (
if (el.href != loc.href
&& (
el.href.split('#')[0] == loc.href.split('#')[0] // internal jump
|| base != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] == '#' && el.href.split(base)[0] != loc.href.split(base)[0] // outside of #base
|| !go(getPathFromBase(el.href), el.title || doc.title) // route not found
) return
}
)) return

@@ -179,18 +176,16 @@ e.preventDefault()

function go(path, title, shouldReplace) {
if (hist) { // if a browser
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
if (!hist) return central[TRIGGER]('emit', getPathFromBase(path))
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}

@@ -197,0 +192,0 @@

@@ -15,12 +15,33 @@ ;(function() {

/**
* Private variables and methods
* Private variables
*/
var callbacks = {},
slice = Array.prototype.slice,
onEachEvent = function(e, fn) { e.replace(/\S+/g, fn) }
slice = Array.prototype.slice
// extend the object adding the observable methods
/**
* Private Methods
*/
/**
* Helper function needed to get and loop all the events in a string
* @param { String } e - event string
* @param {Function} fn - callback
*/
function onEachEvent(e, fn) {
var es = e.split(' '), l = es.length, i = 0
for (; i < l; i++) {
var name = es[i]
if (name) fn(name, i)
}
}
/**
* Public Api
*/
// extend the el object adding the observable methods
Object.defineProperties(el, {
/**
* Listen to the given space separated list of `events` and execute the `callback` each time an event is triggered.
* Listen to the given space separated list of `events` and
* execute the `callback` each time an event is triggered.
* @param { String } events - events ids

@@ -56,3 +77,3 @@ * @param { Function } fn - callback function

else {
onEachEvent(events, function(name) {
onEachEvent(events, function(name, pos) {
if (fn) {

@@ -74,3 +95,4 @@ var arr = callbacks[name]

/**
* Listen to the given space separated list of `events` and execute the `callback` at most once
* Listen to the given space separated list of `events` and
* execute the `callback` at most once
* @param { String } events - events ids

@@ -94,3 +116,4 @@ * @param { Function } fn - callback function

/**
* Execute all callback functions that listen to the given space separated list of `events`
* Execute all callback functions that listen to
* the given space separated list of `events`
* @param { String } events - events ids

@@ -111,3 +134,3 @@ * @returns { Object } el

onEachEvent(events, function(name) {
onEachEvent(events, function(name, pos) {

@@ -117,3 +140,3 @@ fns = slice.call(callbacks[name] || [], 0)

for (var i = 0, fn; fn = fns[i]; ++i) {
if (fn.busy) return
if (fn.busy) continue
fn.busy = 1

@@ -257,3 +280,3 @@ fn.apply(el, fn.typed ? [name].concat(args) : args)

// the stack is needed for redirections
var isRoot = emitStackLevel == 0
var isRoot = emitStackLevel == 0, first
if (MAX_EMIT_STACK_LEVEL <= emitStackLevel) return

@@ -270,6 +293,3 @@

if (isRoot) {
while (emitStack.length) {
emitStack[0]()
emitStack.shift()
}
while (first = emitStack.shift()) first() // stack increses within this call
emitStackLevel = 0

@@ -297,9 +317,9 @@ }

if (el.href != loc.href) {
if (
if (el.href != loc.href
&& (
el.href.split('#')[0] == loc.href.split('#')[0] // internal jump
|| base != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] == '#' && el.href.split(base)[0] != loc.href.split(base)[0] // outside of #base
|| !go(getPathFromBase(el.href), el.title || doc.title) // route not found
) return
}
)) return

@@ -317,18 +337,16 @@ e.preventDefault()

function go(path, title, shouldReplace) {
if (hist) { // if a browser
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
if (!hist) return central[TRIGGER]('emit', getPathFromBase(path))
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}

@@ -335,0 +353,0 @@

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

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

@@ -242,2 +242,8 @@ # Router API

<span class="tag red">Warning</span>
If you remove the `#` from the base, your web server needs to deliver your app no matter what url comes in, because your app, in the browser, is manipulating the url. The web server doesn't know how to handle the URL.
### route.parser(parser[, secondParser])

@@ -244,0 +250,0 @@

@@ -118,3 +118,3 @@ /**

// the stack is needed for redirections
var isRoot = emitStackLevel == 0
var isRoot = emitStackLevel == 0, first
if (MAX_EMIT_STACK_LEVEL <= emitStackLevel) return

@@ -131,6 +131,3 @@

if (isRoot) {
while (emitStack.length) {
emitStack[0]()
emitStack.shift()
}
while (first = emitStack.shift()) first() // stack increses within this call
emitStackLevel = 0

@@ -158,9 +155,9 @@ }

if (el.href != loc.href) {
if (
if (el.href != loc.href
&& (
el.href.split('#')[0] == loc.href.split('#')[0] // internal jump
|| base != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] != '#' && getPathFromRoot(el.href).indexOf(base) !== 0 // outside of base
|| base[0] == '#' && el.href.split(base)[0] != loc.href.split(base)[0] // outside of #base
|| !go(getPathFromBase(el.href), el.title || doc.title) // route not found
) return
}
)) return

@@ -178,18 +175,16 @@ e.preventDefault()

function go(path, title, shouldReplace) {
if (hist) { // if a browser
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}
// Server-side usage: directly execute handlers for the path
if (!hist) return central[TRIGGER]('emit', getPathFromBase(path))
// Server-side usage: directly execute handlers for the path
return central[TRIGGER]('emit', getPathFromBase(path))
path = base + normalize(path)
title = title || doc.title
// browsers ignores the second parameter `title`
shouldReplace
? hist.replaceState(null, title, path)
: hist.pushState(null, title, path)
// so we need to set it manually
doc.title = title
routeFound = false
emit()
return routeFound
}

@@ -196,0 +191,0 @@

{
"name": "riot-route",
"version": "2.4.0",
"version": "2.5.0",
"description": "Simple isomorphic router",

@@ -25,18 +25,18 @@ "main": "lib/index.js",

"dependencies": {
"riot-observable": "^2.4.2"
"riot-observable": "^2.5.0"
},
"devDependencies": {
"chokidar-cli": "^1.2.0",
"coveralls": "^2.11.9",
"eslint": "^2.9.0",
"coveralls": "^2.11.11",
"electron-prebuilt": "^1.3.1",
"eslint": "^3.1.1",
"expect.js": "^0.3.1",
"karma": "^0.13.22",
"karma-browserstack-launcher": "^1.0.0",
"karma-coverage": "^1.0.0",
"karma-mocha": "^1.0.1",
"karma-mocha-reporter": "^2.0.3",
"karma-phantomjs-launcher": "^1.0.0",
"mocha": "^2.4.5",
"phantomjs": "^2.1.7",
"uglify-js": "^2.6.2"
"karma": "^1.1.1",
"karma-browserstack-launcher": "^1.0.1",
"karma-coverage": "^1.1.1",
"karma-electron": "^4.0.0",
"karma-mocha": "^1.1.1",
"karma-mocha-reporter": "^2.0.4",
"mocha": "^2.5.3",
"uglify-js": "^2.7.0"
},

@@ -43,0 +43,0 @@ "author": "Muut, Inc. and other contributors",

@@ -11,3 +11,3 @@ module.exports = function(config) {

} else
browsers = ['PhantomJS']
browsers = ['Electron']

@@ -22,7 +22,6 @@ config.set({

'karma-browserstack-launcher',
'karma-phantomjs-launcher'
'karma-electron'
],
files: [
'../node_modules/expect.js/index.js',
'polyfill.js',
'../dist/route.js',

@@ -29,0 +28,0 @@ 'specs/core.specs.js'

@@ -53,3 +53,3 @@ function fireEvent(node, eventName) {

'<a class="tag-n" href="/other/" target="_self">N</a>' +
'<a class="tag-o" href="/other/" target="_blank">O</a>' +
'<a class="tag-o prevented" href="/other/" target="_blank">O</a>' +
'<a class="tag-p prevented" href="/no-go/">no go</a>' +

@@ -114,6 +114,7 @@ '<p class="tag-z">O</p>'

done
], 10)
], 20)
})
it('ignore link clicked in some cases', function(done) {
route.base('/')
route(function() {

@@ -457,4 +458,3 @@ counter++

/* history.back() doesn't work with PhantomJS
it('push and replace', function() {
it('push and replace', function(done) {
route.base('/')

@@ -464,15 +464,19 @@ route(function() {

})
route('one', 'One')
route('two', 'Two')
history.back()
expect(window.location.pathname).to.be('/one')
route('three', 'Three')
route('four', 'Four')
route('five', 'Five', true)
history.back()
expect(window.location.pathname).to.be('/three')
expect(counter).to.be(5)
serial([
function() { route('one', 'One') },
function() { route('two', 'Two') },
function() { history.back() },
function() { expect(window.location.pathname).to.be('/one') },
function() { route('three', 'Three') },
function() { route('four', 'Four') },
function() { route('five', 'Five', true) },
function() { history.back() },
function() {
expect(window.location.pathname).to.be('/three')
expect(counter).to.be(7)
},
done
], 30)
})
*/
})

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