def map_url_to_job_config(url, config_mapping):
    """Return job name and config of the longest matching URL in the config mapping."""
    job_name, job_config = (None, None)
    match_length = 0
    for candidate_url, match in config_mapping.items():
        if url.startswith(candidate_url) and len(candidate_url) > match_length:
            job_name, job_config = match
            match_length = len(candidate_url)
    return job_name, job_config