New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

the-killer-router

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

the-killer-router - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

44

lib/router.js

@@ -7,3 +7,4 @@ import Routes from './routes';

super();
this.route = {};
this.route = new Map();
this.previousRoute = null;
}

@@ -13,8 +14,11 @@

this._reactComponent = reactComponent;
this.paramRoutes = new Map();
this.routes.forEach((v, key) => /(\:\w*)/g.test(key) ?
this.paramRoutes.set(key, key.split('/')) :
null);
}
evaluteRoute(path) {
if (!this[path] && !/^\w\:\/\//gi.test(path)) {
return this['404'];
}
let view;
const pathParams = path.split('/');

@@ -25,9 +29,35 @@ if (/^\w\:\/\//gi.test(path)) {

return this[path];
if (this.routes.get(path)) {
this.route.clear();
return this.routes.get(path);
}
this.previousRoute = this.actualRoute;
this.paramRoutes.forEach((value, key) => {
const matchParams = pathParams
.filter(param =>
value.find(val => val === param));
if (value.length === pathParams.length &&
matchParams && matchParams.length
) {
value.forEach((val, index) => {
if (pathParams[index] !== val && /\:/gi.test(val))
this.route.set(val, pathParams[index]);
});
view = this.routes.get(key);
}
});
return view;
}
navigate(path, data, title) {
const {view, config} = this.evaluteRoute(path);
const { view, config} = this.evaluteRoute(path);
this.component = view;
this.activeRouteConfig = { config, data };
this.activeRoute = {
...config,
...data
};
history.pushState(null, title, path);

@@ -34,0 +64,0 @@ this._reactComponent && this._reactComponent.forceUpdate();

8

lib/routes.js
class Routes {
constructor() {
this.routes = new Map();
}
add(path, view, config) {
this[path] = {};
if (!arguments.length) return this;
this[path].view = view;
this[path].config = config;
this.routes.set(path, { view, config });
return this;

@@ -8,0 +10,0 @@ }

{
"name": "the-killer-router",
"version": "0.1.1",
"version": "1.0.0",
"description": "A router library for a view frameworks based",

@@ -5,0 +5,0 @@ "main": "index.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