I’m using this function to remove http://, https:// and www. from my URLs.
function cleanUrl2(url) {
return url.replace(/^(http(s)?:\/\/)?(www\.)?/gi,"");
}
My problem is that I sometimes get:
google.com
and sometimes:
google.com/something/
The ‘/’ at the end causes a lot of problems with my database. I need my function to also remove ‘/’ if it’s the last character.
How can I do this?
1 Answer