Cars cz. 2
This commit is contained in:
1 parent
d60f8a91a7
commit
3b96ac1be8
9 files changed
+265
-23
No files matched your search
+8
-8
@@ -31,7 +31,7 @@ const MATCHING_GROUP_REGEXP = /\((?:\?<(.*?)>)?(?!\?)/g
|
||||
|
||||
module.exports = Layer
|
||||
|
||||
function Layer (path, options, fn) {
|
||||
function Layer(path, options, fn) {
|
||||
if (!(this instanceof Layer)) {
|
||||
return new Layer(path, options, fn)
|
||||
}
|
||||
@@ -46,7 +46,7 @@ function Layer (path, options, fn) {
|
||||
this.path = undefined
|
||||
this.slash = path === '/' && opts.end === false
|
||||
|
||||
function matcher (_path) {
|
||||
function matcher(_path) {
|
||||
if (_path instanceof RegExp) {
|
||||
const keys = []
|
||||
let name = 0
|
||||
@@ -59,7 +59,7 @@ function Layer (path, options, fn) {
|
||||
})
|
||||
}
|
||||
|
||||
return function regexpMatcher (p) {
|
||||
return function regexpMatcher(p) {
|
||||
const match = _path.exec(p)
|
||||
if (!match) {
|
||||
return false
|
||||
@@ -103,7 +103,7 @@ function Layer (path, options, fn) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.handleError = function handleError (error, req, res, next) {
|
||||
Layer.prototype.handleError = function handleError(error, req, res, next) {
|
||||
const fn = this.handle
|
||||
|
||||
if (fn.length !== 4) {
|
||||
@@ -139,7 +139,7 @@ Layer.prototype.handleError = function handleError (error, req, res, next) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.handleRequest = function handleRequest (req, res, next) {
|
||||
Layer.prototype.handleRequest = function handleRequest(req, res, next) {
|
||||
const fn = this.handle
|
||||
|
||||
if (fn.length > 3) {
|
||||
@@ -175,7 +175,7 @@ Layer.prototype.handleRequest = function handleRequest (req, res, next) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Layer.prototype.match = function match (path) {
|
||||
Layer.prototype.match = function match(path) {
|
||||
let match
|
||||
|
||||
if (path != null) {
|
||||
@@ -216,7 +216,7 @@ Layer.prototype.match = function match (path) {
|
||||
* @private
|
||||
*/
|
||||
|
||||
function decodeParam (val) {
|
||||
function decodeParam(val) {
|
||||
if (typeof val !== 'string' || val.length === 0) {
|
||||
return val
|
||||
}
|
||||
@@ -236,7 +236,7 @@ function decodeParam (val) {
|
||||
/**
|
||||
* Loosens the given path for path-to-regexp matching.
|
||||
*/
|
||||
function loosen (path) {
|
||||
function loosen(path) {
|
||||
if (path instanceof RegExp || path === '/') {
|
||||
return path
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user