'Applies a new CDN/base URL to the given URL.
If a URL is absolute, we skip switching the host since it could
be a hostname that isn\'t behind our CDN, and we could unintentionally
break the URL overall.'

def _apply_cdn_to_url(self, url, base_url):

    if (not url):
        return url
    (_, netloc, path, params, query, fragment) = urlparse(url)
    if netloc:
        return url
    return urlunparse((None, base_url, path, params, query, fragment))
