remove hostname and port from url using regular expression
You don't need any library or REGEX
var url = new URL('http://localhost:7001/www.facebook.com')
console.log(url.pathname)
https://developer.mozilla.org/en-US/docs/Web/API/URL
Based on @atiruz answer, but this is
url = url.replace( /^[a-zA-Z]{3,5}\:\/{2}[a-zA-Z0-9_.:-]+\//, '' );
- shortest
- can take https or ftp too
- can take url with or without explicit port