def _parse_reference(ref, identifier):
    """
    First try to sniff the scheme from the URL in the `ref` dict with geolinks,
    if that fails get the `scheme` field directly.

    For all possible identifiers see:
    https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv

    """
    from geolinks import sniff_link
    url = None
    scheme = sniff_link(ref['url'])
    if not scheme:
        scheme = ref['scheme']
    if identifier.endswith(':'):
        cond = identifier in scheme
    else:
        cond = identifier == scheme
    if cond:
        url = ref['url']
    return url
