import pathlib


def prefix_path(jp_root_dir, tmp_path):
    """If a given path is prefixed with the literal
    strings `/jp_root_dir` or `/tmp_path`, replace those
    strings with these fixtures.

    Returns a pathlib Path object.
    """
    def _inner(rawpath):
        path = pathlib.PurePosixPath(rawpath)
        if rawpath.startswith('/jp_root_dir'):
            path = jp_root_dir.joinpath(*path.parts[2:])
        elif rawpath.startswith('/tmp_path'):
            path = tmp_path.joinpath(*path.parts[2:])
        return pathlib.Path(path)
    return _inner