Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Express Route Regex Match With Question Mark

Tags:

regex

express

I've been trying to match the following URL:

http://localhost:3000/?uid=Nf83K3L

with app.get(/^\/\?uid.+/, userController.redirectUid) but it's not working.

I've tried to escape the question mark with \? as well, but still doesn't work. Am I doing something wrong, or am I not allowed to match question marks in express routes?

like image 921
Jon Lee Avatar asked Jun 01 '26 12:06

Jon Lee


1 Answers

You don't need the carat(^) as it means / should be the beginning of the string you want to match.

app.get(/\/\?uid.+/, userController.redirectUid).

Hope this fixes your issue.

like image 180
Rowland Avatar answered Jun 04 '26 11:06

Rowland