@staticmethod
def canonical_url(project_url):
    """
        Case insensitive
        Path can contain only letters, digits, '_', '-' and '.'.
        Cannot start with '-', end in '.git' or end in '.atom'

        Implementation is copied from Github API
        """
    url = project_url.lower()
    for chunk in ('http://', 'https://', 'gitlab.com'):
        if url.startswith(chunk):
            url = url[len(chunk):]
    if url.endswith('/'):
        url = url[:-1]
    while url.endswith('.git'):
        url = url[:-4]
    return 'gitlab.com/' + url
