expressjs / expressjs.com

https://expressjs.com
Other
5.25k stars 1.44k forks source link

express 5 router wildcard does not work as documented #1408

Closed david-gang closed 1 week ago

david-gang commented 1 year ago

Hi,

The following does not work as written in the documentation: https://expressjs.com/en/5x/api.html

app.all('*', requireAuthentication, loadUser)

This is because you are at a newer version of path-to-regexp

https://github.com/pillarjs/path-to-regexp#compatibility-with-express--4x

so please update the documentation because this works

app.all('(.*)', requireAuthentication, loadUser)

I think that also the migration doc should reflect this change.

Thanks

david-gang commented 1 year ago

@dougwilson I could open a PR with the documentation changes. English is not my mother tongue so i would prefer that a native english speaker will review the PR. What do you think ?

IamLizu commented 1 month ago

Hey @david-gang 👋

Thank you for your contribution 🎉

You can start this, if you are still here, please respond and I think someone will assign this to you.

david-gang commented 4 weeks ago

Hi,

I am not longer using express actively.

Sorry,

IamLizu commented 4 weeks ago

Hey @david-gang 👋

Its fine.

In that case, I willing to fix it.

cc: @UlisesGascon

IamLizu commented 3 weeks ago

Quick question, I have noticed that express 5.0 is not using path-to-regex, not listed as dependency.. Why is that?

Edit: It appears that express 5 is using router which is using path-to-regexp "3.2.0".

IamLizu commented 1 week ago

We already have PR for this which is ready to be landed,

crandmck commented 1 week ago

Fixed by #1369