How to split a URL into different parts in JS by using regex
For example, consider that the URL saved in the variable q is “http:/security.securethelock.com:443/hey”. After the splitting, the 5 new variables will be created with the following values in it:
If port is not specified, the default value, 80, will be stored. If q is a main domain (and not a subdomain) like “http://www.securethelock.com”, sub = host = securethelock.com . If path is not specified, the corresponding variable will be empty.