Friday Puzzler: How do you strip out subdomains from a URL?
I've had a slew of server problems (more on that later), so instead of a real post, how about a mind boggler? Using, Flex / ActionScript3, write a function that takes a domain string as the input and strips out the subdomains. For example, my domain is "www.jeffryhouser.com". Write some code to give you "jeffryhouser.com". That shouldn't be hard.
But, wait there is more. My local development URL is "local.www.jeffryhouser.com". If I pass it this URL, I want "jeffryhouser.com" returned. So, you'll have to strip out some unknown number of subdomains.
But, wait, there is more. What happens if I'm developing for some country code? Many country codes only allow registration at the third level. If I give you "www.amazon.co.uk", I'll want "amazon.co.uk" returned, not "co.uk".
How would you approach this in Flex? It may or may not help, but here is a great Regex for validating domains. I'll write about my the responses and my own experiences with this later.
Now my personal exposé into server problems.
About two weeks ago (or so) my main server just stopped responding. This brought down The Flex Show, DotComIt, and my e-mail. After many calls to the host I found it was a hardware problem, and they had no backups. I was w/o e-mail for four days while we sorted this out. If you sent me something, and I failed to respond, then assume I didn't get it. Everything appears to be back up and working now. And I've started backing up that remote machine to my local repository.
My other server, the one hosting this blog an the Hartford User Group site went down last week. No e-mail attached to this one thankfully. But, as it turns out, the the server was perfectly fine. It's just I couldn't get to it from the outside. After some scrambling and support calls, the host gave it a new IP. I understand the host spent a full day, verifying and retesting every piece of equipment from where the Internet comes in down to my server. We're unsure what the problem is, but suspect that my hosting provider's Internet provider did something on their end, possibly re-assigning the IP accidentally.
Lots of fun!





There are no comments for this entry.
[Add Comment] [Subscribe to Comments]