remove duplicate forward slashes from the URL

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");

This question has been answered before...

var str = 'http://localhost//example/author/admin///';    
var clean_url = str.replace(/([^:])(\/\/+)/g, '$1/');

alert(clean_url);

DEMO


You can use:

abc.replace(/([^:]\/)\/+/g, "$1");

Working Demo

Update: Already answered by Halcyon