Grabbing a domain name out of a URL using Shortcuts
Recently I needed the ability to grab a domain name (specifically the hostname) out of a URL using Shortcuts.
Assuming that there is more than two parts to the domain name, this works. But if you have and “A” type of url “blah.com” instead of a “CNAME” type like: “www.blah.com”, you’re going to get “com” as a result. So your milage may vary.
I couldn’t find a good way to do this on the Internet, despite several attempts for people to try and figure it out using regex. You can then go on to store the result as a variable and then use the variable anywhere else in the rest of the Shortcut.
Please leave comments below.
*** This is a Security Bloggers Network syndicated blog from Joel Esler authored by Joel Esler. Read the original post at: http://blog.joelesler.net/2023/12/grabbing-domain-name-out-of-url-using.html

