I'm looking to use an API to check the spam status of a user submitted full URL and I'd like to extract just the domain name from it, so I need to turn this: https://www.example.com/test-folder/another/folder
into this:
example.com
I've tried this on the front part: testurl.replace('https://', '').replace('http://', '').replace('www.', '')
but what about removing everything after the forward slash?
I've tried a few variations on 'split' but am missing something simple.
Thank you too @famousmag - I forgot to add it was server side NodeJS (DUH) but I'm going to try it on the front end using the Browser component like you mentioned just for future reference, appreciate your help.
Here is a custom server connect formatter to to extract domain from a url if you want to try it. Just drop it into your extensions/server_connect/formatters folder and you will see it as below