Remove Protocol if at start of string?

How do I remove the protocol if it is only at the start of a string? No jQuery please, only JavaScript!

Input Examples:
1) http//www.mysite.com/?url=http//www.mysite.com
2) https//www.mysite.com/?url=https//www.mysite.com
3) //www.mysite.com/?url=http//www.mysite.com
4) //www.mysite.com/?url=https//www.mysite.com

Output Examples:
1) //www.mysite.com/?url=http//www.mysite.com
2) //www.mysite.com/?url=https//www.mysite.com
3) //www.mysite.com/?url=http//www.mysite.com
4) //www.mysite.com/?url=https//www.mysite.com

Thanks!
894359Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
leakim971Connect With a Mentor PluritechnicianCommented:
var removeHTTPProtocol = function(url) {
    return url.replace(/^https?:/,"")
}

Open in new window

0
 
Pawan KumarDatabase ExpertCommented:
var strRemoveProtocol = (YourString.Replace("https","")).Replace("http","")
0
 
894359Author Commented:
Than you!
0
All Courses

From novice to tech pro — start learning today.