from pathlib import Path


def ensure_extension(filename, extension):
    """
        Ensures of the extension of a file

        >>> ensure_extension('foo.pdf', 'pdf')
        'foo.pdf'
        >>> ensure_extension('bar.csv', 'pdf')
        'bar.pdf'
    """
    return str(Path(filename).with_suffix(f".{extension}"))