Avatar of Rohit Bajaj
Rohit Bajaj
Flag for India

asked on 

Parsing url in javascript

Hi,
I have a user enterable link in my application. If the user does not specify the protocol then i want to add http:// by default to it.
eg. if user enters www.google.com then i want to convert it to http://www.google.com
else if user enters http://www.google.com or https://... i want to keep it same.
basically i want to modify only those strings and prepend it with http:// if no url is specified.

How can i do it in javascript or jquery ?
Thanks
JavaScriptjQuery

Avatar of undefined
Last Comment
Russ Suter

8/22/2022 - Mon