class SlashFilter extends ZuulFilter {

    @Override
    public boolean shouldFilter() {
        RequestContext context = RequestContext.getCurrentContext();
        String url = context.getRequest().getRequestURL().toString().toLowerCase();
        String serviceId = (String) context.get(SERVICE_ID_KEY);
        String proxy = (String) context.get(PROXY_KEY);

        boolean checkProxy = (proxy != null) && REGEX_CONTAINS_UI_PATH.matcher(proxy).find();
        boolean checkServiceId = (serviceId != null) && !serviceId.isEmpty() && url.contains(serviceId);

        boolean oldPathFormatShouldFilter = checkServiceId && url.endsWith(serviceId);
        boolean newPathFormatShouldFilter = checkProxy && REGEX_END_WITH_UI_ROUTE.matcher(url).find();

        return checkProxy && checkServiceId && (oldPathFormatShouldFilter || newPathFormatShouldFilter);
    }

}