@eggjs/router
Advanced tools
+6
-0
| 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 @@ ================== |
@@ -58,3 +58,3 @@ 'use strict'; | ||
| /** | ||
| * @constructor | ||
| * @class | ||
| * @param {Object} opts - Router options. | ||
@@ -61,0 +61,0 @@ * @param {Application} app - Application object. |
+5
-9
@@ -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 @@ }); |
+2
-1
| { | ||
| "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 @@ }, |
+2
-2
@@ -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 |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
58323
0.37%1
-50%1174
-0.25%