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

cycle-routing-driver

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cycle-routing-driver - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

38

dist/react/router.js

@@ -55,5 +55,8 @@ "use strict";

var match = _ref2.match,
strict = _ref2.strict,
children = _ref2.children;
var route = useRoute();
var isMatch = routeMatches(match, route);
var isMatch = routeMatches(match, route, {
strict: strict
});
return isMatch ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children) : null;

@@ -91,5 +94,10 @@ };

function routeMatches(check, route) {
var _ref4 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
strict = _ref4.strict;
switch (_typeof(check)) {
case "string":
return pageMatches(check, route);
return pageMatches(check, route, {
strict: strict
});

@@ -101,3 +109,5 @@ case "function":

default:
return !!check.page && pageMatches(check.page, route) && keysMatch(route.data, check.data) && keysMatch(route.query, check.query);
return !!check.page && pageMatches(check.page, route, {
strict: strict
}) && (!check.data || keysMatch(route.data, check.data)) && (!check.query || keysMatch(route.query, check.query));
}

@@ -107,12 +117,22 @@ }

function pageMatches(page, route) {
var matcher = new RegExp("^".concat(page.replace(".", "."), "(.w*)*$"));
return matcher.test(route.page);
var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
strict = _ref5.strict;
var expected = page.split(".");
var actual = route.page.split(".");
if (strict && expected.length !== actual.length) return false;
return expected.every(function (v, i) {
return v === actual[i];
});
}
function keysMatch(actual, expected) {
var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
strict = _ref6.strict;
if (!expected) return true;
return Object.entries(expected).reduce(function (acc, _ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
key = _ref5[0],
value = _ref5[1];
return Object.entries(expected).reduce(function (acc, _ref7) {
var _ref8 = _slicedToArray(_ref7, 2),
key = _ref8[0],
value = _ref8[1];

@@ -119,0 +139,0 @@ return acc && actual[key] === value;

@@ -228,3 +228,4 @@ "use strict";

stack.push(current);
return routes.push(current.route);
routes.push(current.route);
return;
}

@@ -236,7 +237,8 @@

stack.push(prev, current);
return prev.route.subs.push(current.route);
prev.route.subs.push(current.route);
return;
}
if (prev.indent > current.indent) {
stack = stack.slice(0, prev.indent - current.indent);
stack = stack.slice(0, prev.indent - current.indent - 1);
}

@@ -246,5 +248,6 @@

stack.push(current);
return parent.push(current.route);
parent.push(current.route);
return;
});
return routes;
}
{
"name": "cycle-routing-driver",
"version": "1.2.1",
"version": "1.3.0",
"description": "A bare-bones router for simple frontend routing in CycleJS",

@@ -5,0 +5,0 @@ "main": "dist/routing-driver.js",

@@ -132,2 +132,3 @@ cycle-routing-driver

<Route match="homepage"><Homepage /></Route>
<Route match="post" strict>This doesn't show on subroutes (like post.edit)</Route>
<Route match="post.edit"><EditPost /></Route>

@@ -134,0 +135,0 @@ </main>

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