code: def build_url (self):
          
          # norm base url - can raise UnicodeError from url.idna_encode()
          base_url, is_idn = url_norm(self.base_url, self.encoding)
          # make url absolute
          if self.base_ref:
              # use base reference as parent url
              if ":" not in self.base_ref:
                  # some websites have a relative base reference
                  self.base_ref = urljoin(self.parent_url, self.base_ref)
              self.url = urljoin(self.base_ref, base_url)
          elif self.parent_url:
              # strip the parent url query and anchor
              urlparts = list(urlparse.urlsplit(self.parent_url))
              urlparts[4] = ""
              parent_url = urlutil.urlunsplit(urlparts)
              self.url = urljoin(parent_url, base_url)
          else:
              self.url = base_url
          # urljoin can unnorm the url path, so norm it again
          urlparts = list(urlparse.urlsplit(self.url))
          if urlparts[2]:
              urlparts[2] = urlutil.collapse_segments(urlparts[2])
          self.url = urlutil.urlunsplit(urlparts)
          # split into (modifiable) list
          self.urlparts = strformat.url_unicode_split(self.url)
          self.build_url_parts()
          # and unsplit again
          self.url = urlutil.urlunsplit(self.urlparts)
docs: Construct self.url and self.urlparts out of the given base
          url information self.base_url, self.parent_url and self.base_ref.