Reputation: 890
How to write the regrex rules for the specific given url parameter?
For exmaple, I have URL below:
http://localhost:5008/api/products/productsSubscribeStatus?companyId=14
http://localhost:5008/api/products/productsSubscribeStatus
http://localhost:5008/api/products/productsSubscribeStatus?ccc=14
I want to a rule only match "products/productsSubscribeStatus" and only with the parameter "companyID=xx", but does not pass the url with the other parameters like the third one.
I write the regrex: \/products\/productsSubscribeStatus(\?companyId=\d+$)?
, but it cannot guarantee the parameter is companyId
only.
Upvotes: 0
Views: 401
Reputation: 521457
I would just make the entire expected query parameter optional:
^https?://.+/products/productsSubscribeStatus(?:\?companyId=\w+)?$
Upvotes: 1