URLs are versatile but easy to generate incorrectly, especially when combined from various sources. Fortunately, there are libraries that not only build URLs from their separate parts - scheme, domain, etc. - but also parse and clean badly-formatted ones. Take this example, with extra forward slashes and an unnecessary WWW subdomain: