def get_intern_pattern (url):
    """Return intern pattern for given URL. Redirections to the same
    domain with or without "www." prepended are allowed."""
    parts = strformat.url_unicode_split(url)
    scheme = parts[0].lower()
    domain = parts[1].lower()
    domain, is_idn = urlutil.idna_encode(domain)
    # allow redirection www.example.com -> example.com and vice versa
    if domain.startswith('www.'):
        domain = domain[4:]
    if not (domain and scheme):
        return None
    path = urlutil.splitparams(parts[2])[0]
    segments = path.split('/')[:-1]
    path = "/".join(segments)
    if url.endswith('/'):
        path += '/'
    args = list(re.escape(x) for x in (scheme, domain, path))
    if args[0] in ('http', 'https'):
        args[0] = 'https?'
    args[1] = r"(www\.|)%s" % args[1]
    return "^%s://%s%s" % tuple(args)
def get_intern_pattern ( url ) : parts = strformat . url_unicode_split ( url ) scheme = parts [ 0 ] . lower ( ) domain = parts [ 1 ] . lower ( ) domain , is_idn = urlutil . idna_encode ( domain ) if domain . startswith ( 'www.' ) : domain = domain [ 4 : ] if not ( domain and scheme ) : return None path = urlutil . splitparams ( parts [ 2 ] ) [ 0 ] segments = path . split ( '/' ) [ : - 1 ] path = "/" . join ( segments ) if url . endswith ( '/' ) : path += '/' args = list ( re . escape ( x ) for x in ( scheme , domain , path ) ) if args [ 0 ] in ( 'http' , 'https' ) : args [ 0 ] = 'https?' args [ 1 ] = r"(www\.|)%s" % args [ 1 ] return "^%s://%s%s" % tuple ( args )
Return intern pattern for given URL. Redirections to the same
    domain with or without "www." prepended are allowed.