package GameNationBackEnd.Filters;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

public class RoutingFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {}

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest)request;
        String uri = req.getRequestURI();

        if (uri.startsWith("/api") || uri.startsWith("/oauth") || uri.endsWith(".html") || uri.endsWith(".css") || uri.endsWith(".jpg") || uri.endsWith(".png") || uri.endsWith(".ttf") || uri.endsWith(".js")) {
            chain.doFilter(request, response);
        } else {
            req.getRequestDispatcher("/index.html").forward(request, response);
        }
    }

    @Override
    public void destroy() {}
}

@@ -131,55 +131,257 @@
 on;%0A
-%0Apublic class RoutingFilter implements Filter %7B
+import java.lang.reflect.Array;%0Aimport java.util.Arrays;%0A%0Apublic class RoutingFilter implements Filter %7B%0A%0A    String%5B%5D routeStartWith = %7B %22/api%22, %22/oauth%22, %22/logout%22 %7D;%0A    String%5B%5D routeEndsWith = %7B %22.html%22, %22.css%22, %22.jpg%22, %22.png%22, %22.ttf%22, %22.js%22%7D;%0A
 %0A   
@@ -735,182 +735,128 @@
 if (
-uri.startsWith(%22/api%22) %7C%7C uri.startsWith(%22/oauth%22) %7C%7C uri.endsWith(%22.html%22) %7C%7C uri.endsWith(%22.css%22) %7C%7C uri.endsWith(%22.jpg%22) %7C%7C uri.endsWith(%22.png%22) %7C%7C uri.endsWith(%22.ttf%22) %7C%7C
+Arrays.stream(routeStartWith).anyMatch(start -%3E uri.startsWith(start)) %7C%7C Arrays.stream(routeEndsWith).anyMatch(start -%3E
  uri
@@ -865,21 +865,22 @@
 ndsWith(
-%22.js%22
+start)
 )) %7B%0A   

Refactor route filtering