path-to-regexp icon indicating copy to clipboard operation
path-to-regexp copied to clipboard

How about match an empty array?

Open circlesharp opened this issue 2 years ago • 1 comments

I pass an empty array in match function, then I get trouble:

const { match } = require('path-to-regexp')
urlMatchFn = match([])

console.log(urlMatchFn('/foo')) // { path: '', index: 0, params: [Object: null prototype] {} }

Shoule the result be false? Thanks.

circlesharp avatar Feb 21 '23 06:02 circlesharp

This is an interesting bug, I think it should probably be throwing an error instead.

The issue today is the output regex would be (?:) which would match everything.

blakeembrey avatar Aug 09 '23 19:08 blakeembrey

This has been removed from the API in v7, closing as it no longer needs to be fixed.

blakeembrey avatar Jun 21 '24 00:06 blakeembrey