pub(crate) fn match_route<G: Html>(
    path_slice: &[&str],
    render_cfg: &HashMap<String, String>,
    entities: &EntityMap<G>,
    locales: &Locales,
) -> RouteVerdict {
    let path_vec = path_slice.to_vec();
    let path_joined = PathMaybeWithLocale(path_vec.join("/")); // This should not have a leading forward slash, it's used for asset fetching by
                                                               // the app shell

    // There are different logic chains if we're using i18n, so we fork out early
    if locales.using_i18n && !path_slice.is_empty() {
        let locale = path_slice[0];
        // Check if the 'locale' is supported (otherwise it may be the first section of
        // an uni18ned route)
        if locales.is_supported(locale) {
            // We'll assume this has already been i18ned (if one of your routes has the same
            // name as a supported locale, ffs)
            let path_without_locale = PathWithoutLocale(path_slice[1..].to_vec().join("/"));
            // Get the template to use
            let (entity, was_incremental_match) =
                get_template_for_path(&path_without_locale, render_cfg, entities);
            match entity {
                Some(entity) => RouteVerdict::Found(RouteInfo {
                    locale: locale.to_string(),
                    // This will be used in asset fetching from the server
                    path: path_without_locale,
                    // The user can get the full entity again if they want to, we just use it to
                    // make sure the path exists
                    entity_name: entity.get_path(),
                    was_incremental_match,
                }),
                None => RouteVerdict::NotFound {
                    locale: locale.to_string(),
                },
            }
        } else {
            // If the locale isn't supported, we assume that it's part of a route that still
            // needs a locale (we'll detect the user's preferred)
            // This will result in a redirect, and the actual template to use will be
            // determined after that We'll just pass through the path to be
            // redirected to (after it's had a locale placed in front)
            let path_joined = PathWithoutLocale(path_joined.0);
            RouteVerdict::LocaleDetection(path_joined)
        }
    } else if locales.using_i18n {
        // If we're here, then we're using i18n, but we're at the root path, which is a
        // locale detection point
        let path_joined = PathWithoutLocale(path_joined.0);
        RouteVerdict::LocaleDetection(path_joined)
    } else {
        // We're not using i18n
        let path_joined = PathWithoutLocale(path_joined.0);
        // Get the template to use
        let (entity, was_incremental_match) =
            get_template_for_path(&path_joined, render_cfg, entities);
        match entity {
            Some(entity) => RouteVerdict::Found(RouteInfo {
                locale: locales.default.to_string(),
                // This will be used in asset fetching from the server
                path: path_joined,
                // The user can get the full entity again if they want to, we just use it to make
                // sure the path exists
                entity_name: entity.get_path(),
                was_incremental_match,
            }),
            None => RouteVerdict::NotFound {
                locale: "xx-XX".to_string(),
            },
        }
    }
}
Matches the given path to a `RouteVerdict`. This takes a `TemplateMap` to
match against, the render configuration to index, and it needs to know if
i18n is being used. The path this takes should be raw, it may or may not
have a locale, but should be split into segments by `/`, with empty ones
having been removed.
packages/perseus/src/router/match_route.rs