🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@eggjs/router

Package Overview
Dependencies
Maintainers
14
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eggjs/router - npm Package Compare versions

Comparing version
2.0.0
to
2.0.1
+6
-0
History.md
2.0.1 / 2021-07-12
==================
**fixes**
* [[`2c44ec0`](http://github.com/eggjs/egg-router/commit/2c44ec0bdeff1e8f46d899ed4386d1e28a93a854)] - fix: ensure ctx._matchedRoute and ctx._matchedRouteName to be correct (#7) (Yiyu He <<dead_horse@qq.com>>)
2.0.0 / 2019-02-14

@@ -3,0 +9,0 @@ ==================

+1
-1

@@ -58,3 +58,3 @@ 'use strict';

/**
* @constructor
* @class
* @param {Object} opts - Router options.

@@ -61,0 +61,0 @@ * @param {Application} app - Application object.

@@ -43,3 +43,3 @@ 'use strict';

* @param {String=} opts.prefix prefix router paths
* @constructor
* @class
*/

@@ -179,8 +179,2 @@ constructor(opts) {

const matchedLayers = matched.pathAndMethod;
const mostSpecificLayer = matchedLayers[matchedLayers.length - 1];
ctx._matchedRoute = mostSpecificLayer.path;
if (mostSpecificLayer.name) {
ctx._matchedRouteName = mostSpecificLayer.name;
}
const layerChain = matchedLayers.reduce(function(memo, layer) {

@@ -190,4 +184,6 @@ memo.push(function(ctx, next) {

ctx.params = layer.params(path, ctx.captures, ctx.params);
ctx.routerName = layer.name;
ctx.routerPath = layer.path;
// ctx._matchedRouteName & ctx._matchedRoute for compatibility
ctx._matchedRouteName = ctx.routerName = layer.name;
if (!layer.name) ctx._matchedRouteName = undefined;
ctx._matchedRoute = ctx.routerPath = layer.path;
return next();

@@ -194,0 +190,0 @@ });

{
"name": "@eggjs/router",
"version": "2.0.0",
"version": "2.0.1",
"description": "Router middleware for egg/koa. Provides RESTful resource routing.",

@@ -54,2 +54,3 @@ "repository": {

"ci": {
"type": "github",
"version": "8, 10, 11"

@@ -56,0 +57,0 @@ },

@@ -90,4 +90,4 @@ # @eggjs/router

When a route is matched, its path is available at `ctx._matchedRoute` and if named,
the name is available at `ctx._matchedRouteName`
When a route is matched, its path is available at `ctx.routePath` and if named,
the name is available at `ctx.routeName`

@@ -94,0 +94,0 @@ Route paths will be translated to regular expressions using