Add optional method property in object form of pathFilter

This commit is contained in:
Michal Kaminski
2019-02-06 21:52:17 +01:00
parent d4bda79c6c
commit 9091f4ab0a
2 changed files with 4 additions and 2 deletions

View File

@@ -14,4 +14,6 @@ app.use(middleware.unless({ path: "/index", useOriginalUrl: true }));
app.use(middleware.unless({ path: /home/g, ext: ".jpg" }));
app.use(middleware.unless({ path: { url: "/index" }, ext: [ ".html", ".htm" ] }));
app.use(middleware.unless({ path: { url: "/index", methods: [ "GET", "POST" ] } }));
app.use(middleware.unless({ path: [ "/index", "/home", /home/i, { url: "/main", methods: [ "GET" ] }, { url: /home/i } ] }));
app.use(middleware.unless({ path: [ "/index", "/home", /home/i, { url: "/main", methods: [ "GET" ] }, { url: /home/i } ] }));
app.use(middleware.unless({ path: [ "/index", "/home", /home/i, { url: "/main", method: "GET" }, { url: /home/i } ] }));
app.use(middleware.unless({ path: [ "/index", "/home", /home/i, { url: "/main", method: [ "GET" ] }, { url: /home/i } ] }));

View File

@@ -12,7 +12,7 @@ declare function unless(options: unless.Options): express.RequestHandler;
declare function unless(options: unless.Options["custom"]): express.RequestHandler;
declare namespace unless {
type pathFilter = string | RegExp | { url: string | RegExp, methods?: string[] };
type pathFilter = string | RegExp | { url: string | RegExp, methods?: string[], method?: string | string[] };
export interface Options {
custom?: (req: express.Request) => boolean;