code: def urljoin(refurl, objurl):
      
      if objurl.strip() in ('', '#'):
          return ''
      elif objurl.startswith('http'):
          return objurl
      elif objurl.startswith('/'):
          refurl = refurl.replace('//', '{$$}')
          return ''.join([refurl[:refurl.index('/')].replace('{$$}', '//'), objurl])
      else:
          return '/'.join([refurl[:refurl.rindex('/')], objurl])
docs: >>> urljoin('http://www.homeinns.com/hotel', 'http://www.homeinns.com/beijing')
      'http://www.homeinns.com/beijing'
      >>> urljoin('http://www.homeinns.com/hotel', '/beijing')
      'http://www.homeinns.com/beijing'
      >>> urljoin('http://www.homeinns.com/hotel', 'beijing')
      'http://www.homeinns.com/beijing'