class ContextPathFilter implements Filter {
    private final String contextPath0;
    private final String contextPath1;
    private final boolean forced;

    public ContextPathFilter() {
        this(Solon.cfg().serverContextPath(), Solon.cfg().serverContextPathForced());
    }

    /**
     * @deprecated 2.6
     * */
    @Deprecated
    public ContextPathFilter(boolean forced) {
        this(Solon.cfg().serverContextPath(), forced);
    }

    /**
     * @deprecated 2.6
     * */
    @Deprecated
    public ContextPathFilter(String contextPath) {
        this(contextPath, false);
    }

    /**
     * @param contextPath '/demo/'
     */
    public ContextPathFilter(String contextPath, boolean forced) {
        this.forced = forced;

        if (Utils.isEmpty(contextPath)) {
            contextPath0 = null;
            contextPath1 = null;
        } else {
            String newPath = null;
            if (contextPath.endsWith("/")) {
                newPath = contextPath;
            } else {
                newPath = contextPath + "/";
            }

            if (newPath.startsWith("/")) {
                this.contextPath1 = newPath;
            } else {
                this.contextPath1 = "/" + newPath;
            }

            this.contextPath0 = contextPath1.substring(0, contextPath1.length() - 1);

            //有可能是 ContextPathFilter 是用户手动添加的！需要补一下配置
            Solon.cfg().serverContextPath(this.contextPath1);
        }
    }


    @Override
    public void doFilter(Context ctx, FilterChain chain) throws Throwable {<FILL_FUNCTION_BODY>}
}

        if (contextPath0 != null) {
            if (ctx.pathNew().equals(contextPath0)) {
                //www:888 加 abc 后，仍可以用 www:888/abc 打开
                ctx.pathNew("/");
            } else if (ctx.pathNew().startsWith(contextPath1)) {
                ctx.pathNew(ctx.pathNew().substring(contextPath1.length() - 1));
            } else {
                if (forced) {
                    return;
                }
            }
        }

        chain.doFilter(ctx);
    
<no_super_class>