import re
import requests


def check_github(repository: str) -> str:
    """Check if the repository is valid and exists, returning full URL"""
    if not repository.startswith("https://"):
        if not re.match(r"\w+/\w+", repository):
            raise ValueError("Invalid repository name, format should be full repository URL or userame/repository")
        repository = f"https://github.com/{repository}"
    resp = requests.head(repository)
    if resp.status_code != 200:
        raise ValueError(
            f"Repository does not exist or access denied (url: {repository}, status: {resp.status_code}")
    return repository