import re


def fix_gitlab_links(base_url, text):
    """
    Fixes gitlab upload links that are relative and makes them absolute
    """

    matches = re.findall('(\[[^]]*\]\s*\((/[^)]+)\))', text)

    for (replace_string, link) in matches:
        new_string = replace_string.replace(link, base_url + link)
        text = text.replace(replace_string, new_string)

    return text