# Path: src/ronkyuu/tools.py
# def normalizeURL(targetURL):
#     """Return the last URL (of any redirections) of a valid URL
#     """
#     result = None
#     ok, chain = getURLChain(targetURL)
#     if ok:
#         if len(chain) > 0:
#             result = chain[-1]
#         else:
#             result = targetURL
#     return result
# 
# def cleanURL(targetURL):
#     """Return from the given URL a "clean" URL that follows the RFC guidelines
#     """
#     scheme, netloc, path, query, fragment = urlsplit(targetURL)
#     if len(path) == 0:
#         path = '/'
#     return urlunsplit((scheme, netloc, path, query, fragment))


from urllib.parse import urlparse
from bs4 import BeautifulSoup
from .tools import normalizeURL, cleanURL
import requests
            if rel is not None and href is not None:
                url = urlparse(href)
                if url is not None and url.scheme in ('http', 'https'):
                    result['relme'].append(cleanURL(href))
    return result


def confirmRelMe(profileURL, resourceURL, profileRelMes=None, resourceRelMes=None):
    """Determine if a given :resourceURL: is authoritative for the :profileURL:

    TODO add https/http filtering for those who wish to limit/restrict urls to match fully
    TODO add code to ensure that each item in the redirect chain is authoritative

    :param profileURL: URL of the user
    :param resourceURL: URL of the resource to validate
    :param profileRelMes: optional list of rel="me" links within the profile URL
    :param resourceRelMes: optional list of rel="me" links found within resource URL
    :rtype: True if confirmed
    """
    result  = False
    profile = normalizeURL(profileURL)

    if profileRelMes is None:
        profileRelMe = findRelMe(profileURL)
        profileRelMes = profileRelMe['relme']
    if resourceRelMes is None:
        resourceRelMe = findRelMe(resourceURL)
        resourceRelMes = resourceRelMe['relme']

    for url in resourceRelMes:

# Path: src/ronkyuu/tools.py
# def normalizeURL(targetURL):
#     """Return the last URL (of any redirections) of a valid URL
#     """
#     result = None
#     ok, chain = getURLChain(targetURL)
#     if ok:
#         if len(chain) > 0:
#             result = chain[-1]
#         else:
#             result = targetURL
#     return result
# 
# def cleanURL(targetURL):
#     """Return from the given URL a "clean" URL that follows the RFC guidelines
#     """
#     scheme, netloc, path, query, fragment = urlsplit(targetURL)
#     if len(path) == 0:
#         path = '/'
#     return urlunsplit((scheme, netloc, path, query, fragment))


# Path: src/ronkyuu/relme.py
from urllib.parse import urlparse
from bs4 import BeautifulSoup
from .tools import normalizeURL, cleanURL
import requests

            if rel is not None and href is not None:
                url = urlparse(href)
                if url is not None and url.scheme in ('http', 'https'):
                    result['relme'].append(cleanURL(href))
    return result


def confirmRelMe(profileURL, resourceURL, profileRelMes=None, resourceRelMes=None):
    """Determine if a given :resourceURL: is authoritative for the :profileURL:

    TODO add https/http filtering for those who wish to limit/restrict urls to match fully
    TODO add code to ensure that each item in the redirect chain is authoritative

    :param profileURL: URL of the user
    :param resourceURL: URL of the resource to validate
    :param profileRelMes: optional list of rel="me" links within the profile URL
    :param resourceRelMes: optional list of rel="me" links found within resource URL
    :rtype: True if confirmed
    """
    result  = False
    profile = normalizeURL(profileURL)

    if profileRelMes is None:
        profileRelMe = findRelMe(profileURL)
        profileRelMes = profileRelMe['relme']
    if resourceRelMes is None:
        resourceRelMe = findRelMe(resourceURL)
        resourceRelMes = resourceRelMe['relme']

    for url in resourceRelMes:

        if profile in (url, normalizeURL(url)):