Below are the ajax urls
displayed in a specific format:
http://example.com/v1/components/compId
http://example.com/v1/machine/machineId
http://example.com/v1/graph/startTime=value?endtime=value
http://example.com/v1/graph/startDate=value?enddate=value?startTime=value?endtime=value
I am trying to validate these url patterns using JavaScript. I have applied a regular expression like:
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
However, it is giving a true result for http://example.com/v1/machine/machineId and
http://example.com/v1 (this should return false).
Please suggest if there is a way to accurately validate the above URLs
Thank you in advance.