def afs_url(file_path):
default_afs_path = '<STR_LIT>'<EOL>afs_path = current_app.config.get('<STR_LIT>', default_afs_path)<EOL>if file_path is None:<EOL><INDENT>return<EOL><DEDENT>if file_path.startswith('<STR_LIT>'):<EOL><INDENT>file_path = os.path.relpath(file_path, '<STR_LIT>')<EOL>file_path = os.path.join(afs_path, file_path)<EOL>return urllib.parse.urljoin('<STR_LIT>', urllib.request.pathname2url(file_path.encode('<STR_LIT:utf-8>')))<EOL><DEDENT>return file_path<EOL>
Convert a file path to a URL pointing to its path on AFS.

    If ``file_path`` doesn't start with ``/opt/cds-invenio/``, and hence is not on
    AFS, it returns it unchanged.

    The base AFS path is taken from the Flask app config if present, otherwise
    it falls back to ``/afs/cern.ch/project/inspire/PROD``.