gravitino
gravitino copied to clipboard
[Improvement] Fix WebUIFilter so that UI routes ending in a trailing slash resolve to index.html
What would you like to be improved?
In server/src/main/java/org/apache/gravitino/server/web/ui/WebUIFilter.java fix UI routes ending in a trailing slash resolve to index.html.
Here's some unit tests to help:
@Test
public void testDirectoryRequestForwardsToIndexHtml() throws ServletException, IOException {
WebUIFilter filter = new WebUIFilter();
HttpServletRequest request = mock(HttpServletRequest.class);
ServletResponse response = mock(ServletResponse.class);
FilterChain chain = mock(FilterChain.class);
RequestDispatcher dispatcher = mock(RequestDispatcher.class);
when(request.getRequestURI()).thenReturn("/ui/section/");
when(request.getRequestDispatcher("/ui/section/index.html")).thenReturn(dispatcher);
filter.doFilter(request, response, chain);
verify(dispatcher).forward(request, response);
verify(chain, never()).doFilter(any(), any());
}
@Test
public void testHtmlRequestWithoutExtensionAppendsHtml() throws ServletException, IOException {
WebUIFilter filter = new WebUIFilter();
HttpServletRequest request = mock(HttpServletRequest.class);
ServletResponse response = mock(ServletResponse.class);
FilterChain chain = mock(FilterChain.class);
RequestDispatcher dispatcher = mock(RequestDispatcher.class);
when(request.getRequestURI()).thenReturn("/ui/dashboard");
when(request.getRequestDispatcher("/ui/dashboard.html")).thenReturn(dispatcher);
filter.doFilter(request, response, chain);
verify(dispatcher).forward(request, response);
verify(chain, never()).doFilter(any(), any());
}
How should we improve?
No response
Hello, can I work in this issue?
Sure, if you have any questions just ask.