jfromaniello / express-unless

Conditionally add a middleware to express with some common patterns
MIT License
178 stars 27 forks source link

use module `path-to-regexp` for path #14

Open safareli opened 8 years ago

safareli commented 8 years ago

It will be nice if we use path-to-regexp so we could use express like path format instead of writing regex directly.

akshay-nm commented 2 years ago

I am doing this:

 .unless({
  path: [
    { url: pathToRegexp('/something/:somethingElse'), methods: ["POST"] }
  ]
})
jfromaniello commented 2 years ago

cool! I know this is a very old thread, I am not sure how can we do this as currently if url is string we do a equal comparison https://github.com/jfromaniello/express-unless/blob/98b362149f9f746f3dcb01d274171b6e37a55d12/src/index.ts#L78-L80