import re


def clean_url(url):
    """Return clean post URL without UTM code at the end."""

    # Pattern that match a link to an Instagram post.
    match = re.match(
        "^http[s]?://www.instagram.com/[ptv]{1,2}/[a-zA-Z0-9_-]{11}", url
    )
    # Shut down the program if the URL didn't match the pattern.
    if not match:
        raise SystemExit("Didn't match a post url.")
    # If the link had any UTM code, it's now removed.
    clean_url = match.group()

    return clean_url