delvedor / find-my-way

A crazy fast HTTP router
MIT License
1.45k stars 133 forks source link

Resolving "Error: Wildcard must be the last character in the route" #378

Open Tayvon opened 1 month ago

Tayvon commented 1 month ago

What's the recommended way of dealing with this error?

Example paths:

/^\/-\/all.*/
/(\/(.*)\.tgz)\/-rev\/(?:.*)/
mcollina commented 1 month ago

I would recommend you to check the readme. You can't specify routes as regexp directly.

In this sense, there is a bug: we should throw if we encounter one.

Checkout the readme.

Tayvon commented 1 month ago

Great, thank you.

Tayvon commented 1 month ago

After reading the README over a few times, i'm still unable to get past this error. I added in the allowUnsafeRegex option, and the previous behavior remains.

Are you suggesting that regexp cant be used unless it's form adheres to the few examples outlined in the README?

Tayvon commented 1 month ago

What's the intuition behind not allowing a wildcard to exist in a regexp unless it's at the end of the expression?