code: def is_local_url(target):
      
      ref_url = urlparse(cfg.get('CFG_SITE_SECURE_URL'))
      test_url = urlparse(urljoin(cfg.get('CFG_SITE_SECURE_URL'), target))
      return test_url.scheme in ('http', 'https') and \
          ref_url.netloc == test_url.netloc
docs: Determine if URL is a local.