Replace custom function with urlparse.urljoin.