koa-router
Advanced tools
Comparing version 9.1.0 to 9.4.0
@@ -1,2 +0,1 @@ | ||
const debug = require('debug')('koa-router'); | ||
const { pathToRegexp, compile, parse } = require('path-to-regexp'); | ||
@@ -45,4 +44,2 @@ const { parse: parseUrl, format: formatUrl } = require('url'); | ||
this.regexp = pathToRegexp(path, this.paramNames, this.opts); | ||
debug('defined route %s %s', this.methods, `${this.opts.prefix}${this.path}`); | ||
}; | ||
@@ -137,3 +134,3 @@ | ||
replace = params; | ||
} else { | ||
} else if (!options) { | ||
options = params; | ||
@@ -140,0 +137,0 @@ } |
@@ -13,2 +13,3 @@ /** | ||
const Layer = require('./layer'); | ||
const { pathToRegexp } = require('path-to-regexp'); | ||
@@ -293,3 +294,6 @@ /** | ||
} else { | ||
router.register(path || '(.*)', [], m, { end: false, ignoreCaptures: !hasPath }); | ||
const keys = []; | ||
pathToRegexp(router.opts.prefix || '', keys); | ||
const routerPrefixHasParam = router.opts.prefix && keys.length; | ||
router.register(path || '([^\/]*)', [], m, { end: false, ignoreCaptures: !hasPath && !routerPrefixHasParam }); | ||
} | ||
@@ -363,3 +367,3 @@ } | ||
ctx.captures = layer.captures(path, ctx.captures); | ||
ctx.params = layer.params(path, ctx.captures, ctx.params); | ||
ctx.params = ctx.request.params = layer.params(path, ctx.captures, ctx.params); | ||
ctx.routerPath = layer.path; | ||
@@ -590,2 +594,4 @@ ctx.routerName = layer.name; | ||
debug('defined route %s %s', route.methods, route.path); | ||
return route; | ||
@@ -592,0 +598,0 @@ }; |
{ | ||
"name": "koa-router", | ||
"description": "Router middleware for koa. Provides RESTful resource routing.", | ||
"version": "9.1.0", | ||
"version": "9.4.0", | ||
"author": "Alex Mingoia <talk@alexmingoia.com>", | ||
@@ -6,0 +6,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35567
873