2021年3月9日星期二

How to identify that a URL path string contains path params in javascript?

So what I am trying to do is to identify if a URL path string contains any path params or not. For example:

  1. /product/1/detail ==> this should be identified as true
  2. /user/sam/detail ===> this should be identified as true
  3. /product ===> this should be identified as false

Further, I will also have a dictionary that is list of similar URl paths ie

[ '/product/5/detail', '/user/ram/detail' ]

I do not if this will be helpful for checking patterns or any formation.

Realy have been stuck with this issue since days. Eagerly awaiting for any help.

https://stackoverflow.com/questions/66558240/how-to-identify-that-a-url-path-string-contains-path-params-in-javascript March 10, 2021 at 12:08PM

没有评论:

发表评论