I am attempting to split url strings into substrings so that I am only working with the domain name of the website e.g. https://nodejs.org/api/console.html should be nodejs.org and http://postgresql.com should be postgresql.com
I have tried solving this issue with the following line of code:
filePath[i].split('/').pop()
But this only works for the urls that do not contain files after the domain e.g. http://postgresql.com
How could I achieve this result?