express-unless
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -7,2 +7,3 @@ import * as express from 'express'; | ||
}; | ||
export declare type RequestChecker = (req: express.Request) => boolean; | ||
export declare type Params = { | ||
@@ -13,3 +14,4 @@ method?: string | string[]; | ||
useOriginalUrl?: boolean; | ||
} | ((req: express.Request) => boolean); | ||
custom?: RequestChecker; | ||
} | RequestChecker; | ||
export declare function unless(options: Params): { | ||
@@ -16,0 +18,0 @@ (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void>; |
@@ -17,3 +17,5 @@ "use strict"; | ||
const middleware = this; | ||
const opts = Object.assign(Object.assign({}, options), (typeof options === 'function' ? { custom: options } : {})); | ||
const opts = typeof options === 'function' ? | ||
{ custom: options } : | ||
options; | ||
opts.useOriginalUrl = (typeof opts.useOriginalUrl === 'undefined') ? true : opts.useOriginalUrl; | ||
@@ -41,3 +43,3 @@ const result = function (req, res, next) { | ||
skip = skip || exts.some(function (ext) { | ||
return url.pathname.substr(ext.length * -1) === ext; | ||
return url.pathname.slice(ext.length * -1) === ext; | ||
}); | ||
@@ -44,0 +46,0 @@ } |
{ | ||
"name": "express-unless", | ||
"description": "Conditionally add a middleware to express with some common patterns.", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": { |
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
7915
97