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

baobab-router

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baobab-router - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

290

baobab-router.dist.js

@@ -7,7 +7,7 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; /**
* ***********************
* PRIVATE STATIC METHODS:
* ***********************
*/
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
* ***********************
* PRIVATE STATIC METHODS:
* ***********************
*/

@@ -81,4 +81,4 @@

function __resolveURL(url) {
var dyn = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var qry = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var dyn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var qry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

@@ -91,3 +91,3 @@ var hash = url.split('/').map(function (s) {

}).map(function (k) {
return escape(k) + '=' + escape(_typeof(qry[k]) === 'object' && qry[k] ? JSON.stringify(qry[k]) : '' + qry[k]);
return escape(k) + '=' + escape(qry[k]);
}).join('&');

@@ -161,4 +161,4 @@

function __deepMerge() {
var res = undefined;
var merged = undefined;
var res = void 0;
var merged = void 0;
var conflicts = false;

@@ -284,37 +284,37 @@

} else if (routeState && (typeof routeState === 'undefined' ? 'undefined' : _typeof(routeState)) === 'object') {
if (!state || (typeof state === 'undefined' ? 'undefined' : _typeof(state)) !== 'object') {
return null;
}
if (!state || (typeof state === 'undefined' ? 'undefined' : _typeof(state)) !== 'object') {
return null;
}
for (var k in routeState) {
if (routeState.hasOwnProperty(k)) {
var localResults = __doesStateMatch(routeState[k], state[k], dynamics, query);
if (localResults) {
results = __deepMerge(results, localResults).value;
} else {
return null;
}
for (var k in routeState) {
if (routeState.hasOwnProperty(k)) {
var localResults = __doesStateMatch(routeState[k], state[k], dynamics, query);
if (localResults) {
results = __deepMerge(results, localResults).value;
} else {
return null;
}
}
}
return results;
return results;
// Dynamics:
} else if (~(dynamics || []).indexOf(routeState) && state) {
results[routeState] = state;
return results;
// Dynamics:
} else if (~(dynamics || []).indexOf(routeState) && state) {
results[routeState] = state;
return results;
// Query:
} else if (~(query || []).indexOf(routeState) && ! ~(dynamics || []).indexOf(routeState)) {
results[routeState] = state;
return results;
// Query:
} else if (~(query || []).indexOf(routeState) && !~(dynamics || []).indexOf(routeState)) {
results[routeState] = state;
return results;
// Null / undefined cases:
} else if ((routeState === undefined || routeState === null) && (state === undefined || state === null)) {
return results;
// Null / undefined cases:
} else if ((routeState === undefined || routeState === null) && (state === undefined || state === null)) {
return results;
// Other scalars:
} else if (routeState === state) {
return results;
}
// Other scalars:
} else if (routeState === state) {
return results;
}

@@ -342,5 +342,5 @@ return null;

function __extractPaths(state) {
var dynamics = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];
var results = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
var path = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3];
var dynamics = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var results = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];

@@ -354,3 +354,3 @@ for (var i in state) {

value: state[i],
dynamic: !! ~dynamics.indexOf(state[i])
dynamic: !!~dynamics.indexOf(state[i])
});

@@ -386,10 +386,8 @@ }

function __makeRoutes(route, solver, baseTree, baseQuery) {
var basePath = arguments.length <= 4 || arguments[4] === undefined ? '' : arguments[4];
var basePath = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
var _deepMerge = __deepMerge(baseTree || {}, route.state ? { state: route.state } : {});
var _deepMerge = __deepMerge(baseTree || {}, route.state ? { state: route.state } : {}),
value = _deepMerge.value,
conflicts = _deepMerge.conflicts;
var value = _deepMerge.value;
var conflicts = _deepMerge.conflicts;
route.fullPath = __concatenatePaths(basePath, route.path);

@@ -486,6 +484,6 @@ route.fullTree = value;

var _watcher = undefined;
var _hashInterval = undefined;
var _hashListener = undefined;
var _watcherListener = undefined;
var _watcher = void 0;
var _hashInterval = void 0;
var _hashListener = void 0;
var _watcherListener = void 0;
var _stored = window.location.hash.replace(/^#/, '');

@@ -510,4 +508,4 @@

var doCommit = undefined;
var doForceCommit = undefined;
var doCommit = void 0;
var doForceCommit = void 0;
var path = basePath || '';

@@ -540,66 +538,70 @@

if (match && !route.defaultRoute) {
var _ret = function () {
var queryValues = query.split('&').reduce(function (res, str) {
var arr = str.split('=');
var queryObj = (route.fullQuery || {})[unescape(arr[0])] || {};
var value = unescape(arr[1]);
var queryValues = query.split('&').reduce(function (res, str) {
var arr = str.split('=');
var queryObj = (route.fullQuery || {})[unescape(arr[0])] || {};
var value = unescape(arr[1]);
switch (queryObj.cast) {
case 'number':
value = +value;
break;
case 'boolean':
value = value === 'true' ? true : false;
break;
case 'json':
try {
value = value ? JSON.parse(value) : null;
} catch (e) {
value = null;
}
break;
default:
// Nothing actually...
}
switch (queryObj.cast) {
case 'number':
value = +value;
break;
case 'boolean':
value = value === 'true' ? true : false;
break;
case 'base64':
try {
value = value ? JSON.parse(atob(value)) : null;
} catch (e) {
value = null;
}
break;
case 'json':
try {
value = value ? JSON.parse(value) : null;
} catch (e) {
value = null;
}
break;
default:
// Nothing actually...
}
if (queryObj.match) {
res[queryObj.match] = value;
return res;
}, {});
}
// Apply updates:
route.updates.map(function (obj) {
var update = {
path: obj.path,
value: obj.value
};
return res;
}, {});
if (obj.dynamic) {
update.value = hash[route.fullPath.split('/').indexOf(update.value)] || queryValues[update.value];
}
// Apply updates:
route.updates.map(function (obj) {
var update = {
path: obj.path,
value: obj.value
};
if (_routesTree.readOnly.every(function (str) {
return !__compareArrays(update.path, str);
}) && update.path.length > 1) {
if (!(0, _lodash2.default)(_tree.get(update.path.slice(1)), update.value)) {
_tree.set(update.path.slice(1), update.value);
doCommit = true;
} else {
doForceCommit = true;
}
if (obj.dynamic) {
update.value = hash[route.fullPath.split('/').indexOf(update.value)] || queryValues[update.value];
}
if (_routesTree.readOnly.every(function (str) {
return !__compareArrays(update.path, str);
}) && update.path.length > 1) {
if (!(0, _lodash2.default)(_tree.get(update.path.slice(1)), update.value)) {
_tree.set(update.path.slice(1), update.value);
doCommit = true;
} else {
doForceCommit = true;
}
});
// Commit only if something has actually been updated:
if (doCommit) {
_tree.commit();
} else if (doForceCommit) {
_checkState(); //eslint-disable-line
}
});
return {
v: true
};
}();
// Commit only if something has actually been updated:
if (doCommit) {
_tree.commit();
} else if (doForceCommit) {
_checkState(); //eslint-disable-line
}
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
return true;
}

@@ -615,3 +617,3 @@ }

function _updateHash(hash) {
var force = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

@@ -656,32 +658,26 @@ if (_stored !== hash || force) {

if (!arguments.length) {
var _ret2 = function () {
_stored = null;
_stored = null;
var restrictedTree = __extractPaths(tree).filter(function (obj) {
return _routesTree.readOnly.some(function (path) {
return __compareArrays(obj.path, path);
});
}).reduce(function (res, obj) {
obj.path.reduce(function (localTree, string, i) {
if (i === obj.path.length - 1) {
localTree[string] = obj.value;
} else {
localTree[string] = localTree[string] || (typeof obj.path[i + 1] === 'number' ? [] : {});
}
var restrictedTree = __extractPaths(tree).filter(function (obj) {
return _routesTree.readOnly.some(function (path) {
return __compareArrays(obj.path, path);
});
}).reduce(function (res, obj) {
obj.path.reduce(function (localTree, string, i) {
if (i === obj.path.length - 1) {
localTree[string] = obj.value;
} else {
localTree[string] = localTree[string] || (typeof obj.path[i + 1] === 'number' ? [] : {});
}
return localTree[string];
}, res);
return res;
}, {});
return localTree[string];
}, res);
return res;
}, {});
if (route.routes.some(function (child) {
return _checkState(route.fullPath, child, restrictedTree);
})) {
return {
v: true
};
}
}();
if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v;
if (route.routes.some(function (child) {
return _checkState(route.fullPath, child, restrictedTree);
})) {
return true;
}
}

@@ -694,3 +690,23 @@

if (route.fullQuery.hasOwnProperty(k)) {
query[k] = match[route.fullQuery[k].match];
var queryObj = route.fullQuery[k];
var value = match[route.fullQuery[k].match];
switch (queryObj.cast) {
case 'json':
if (value) {
value = JSON.stringify(value);
}
break;
case 'base64':
if (value) {
value = btoa(JSON.stringify(value));
}
break;
default:
// Nothing actually...
}
if (value !== undefined && value !== null) {
query[k] = value;
}
}

@@ -791,3 +807,3 @@ }

// Baobab-Router version:
BaobabRouter.version = '2.2.3';
BaobabRouter.version = '2.3.0';

@@ -794,0 +810,0 @@ // Expose private methods for unit testing:

@@ -78,7 +78,3 @@ /**

.filter(k => qry[k] !== null && qry[k] !== undefined)
.map(k => escape(k) + '=' + escape(
(typeof qry[k] === 'object' && qry[k]) ?
JSON.stringify(qry[k]) :
('' + qry[k])
))
.map(k => escape(k) + '=' + escape(qry[k]))
.join('&');

@@ -583,2 +579,11 @@

break;
case 'base64':
try {
value = value ?
JSON.parse(atob(value)) :
null;
} catch (e) {
value = null;
}
break;
case 'json':

@@ -597,3 +602,6 @@ try {

res[queryObj.match] = value;
if (queryObj.match) {
res[queryObj.match] = value;
}
return res;

@@ -738,3 +746,23 @@ }, {});

if (route.fullQuery.hasOwnProperty(k)) {
query[k] = match[route.fullQuery[k].match];
const queryObj = route.fullQuery[k];
let value = match[route.fullQuery[k].match];
switch (queryObj.cast) {
case 'json':
if (value) {
value = JSON.stringify(value);
}
break;
case 'base64':
if (value) {
value = btoa(JSON.stringify(value));
}
break;
default:
// Nothing actually...
}
if (value !== undefined && value !== null) {
query[k] = value;
}
}

@@ -856,3 +884,3 @@ }

// Baobab-Router version:
BaobabRouter.version = '2.2.3';
BaobabRouter.version = '2.3.0';

@@ -859,0 +887,0 @@ // Expose private methods for unit testing:

{
"name": "baobab-router",
"version": "2.2.3",
"version": "2.3.0",
"description": "A router for Baobab",

@@ -5,0 +5,0 @@ "main": "baobab-router.dist.js",

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