With my current function:
http://piza.com/something returns pizza.com
How do I change it so it doesn’t remove what’s after / but keeps removing http, https and www?
E.G:
http://piza.com/something/1 should return pizza.com/something/1
function cleanUrl(url) {
return url.replace(/^(http(s)?:\/\/)?(www\.)?([^\/]+)(\/.*)?$/gi,"$4");
}
Try before you ask. So many regex questions on stackoverflow are basically ‘write my regex’.
Anyway, something like this should work (untested):