How can I remove duplicate forward slashes from the a url, but keep the // which comes after http: so that the URL does not break.
http:
http://localh
I know there're different answers solving the same problem, just another approach :)
var s = "http://www.some-url.com//path//to"; var res = s.replace(/(https?:\/\/)|(\/)+/g, "$1$2");