mirror of https://github.com/halo-dev/halo
Fix admin index page redirect (#566)
* Add custom RequestMappingHandlerMapping for enable static resources access * Fix admin index page redirectpull/565/head
parent
75b5c9efba
commit
84b6c2aa14
|
@ -236,8 +236,7 @@ public class WebMvcAutoConfiguration extends WebMvcConfigurationSupport {
|
||||||
|
|
||||||
private void initBlackPatterns() {
|
private void initBlackPatterns() {
|
||||||
String uploadUrlPattern = ensureBoth(haloProperties.getUploadUrlPrefix(), URL_SEPARATOR) + "**";
|
String uploadUrlPattern = ensureBoth(haloProperties.getUploadUrlPrefix(), URL_SEPARATOR) + "**";
|
||||||
String adminPathPattern = ensureBoth(haloProperties.getAdminPath(), URL_SEPARATOR) + "**";
|
String adminPathPattern = ensureBoth(haloProperties.getAdminPath(), URL_SEPARATOR) + "?*/**";
|
||||||
|
|
||||||
|
|
||||||
blackPatterns.add("/themes/**");
|
blackPatterns.add("/themes/**");
|
||||||
blackPatterns.add("/js/**");
|
blackPatterns.add("/js/**");
|
||||||
|
|
|
@ -11,6 +11,7 @@ import run.halo.app.model.properties.BlogProperties;
|
||||||
import run.halo.app.model.support.HaloConst;
|
import run.halo.app.model.support.HaloConst;
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.service.UserService;
|
import run.halo.app.service.UserService;
|
||||||
|
import run.halo.app.utils.HaloUtils;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -48,7 +49,7 @@ public class MainController {
|
||||||
|
|
||||||
@GetMapping("${halo.admin-path:admin}")
|
@GetMapping("${halo.admin-path:admin}")
|
||||||
public void admin(HttpServletResponse response) throws IOException {
|
public void admin(HttpServletResponse response) throws IOException {
|
||||||
String adminIndexRedirectUri = StringUtils.appendIfMissing(this.haloProperties.getAdminPath(), "/") + INDEX_REDIRECT_URI;
|
String adminIndexRedirectUri = HaloUtils.ensureBoth(haloProperties.getAdminPath(), HaloUtils.URL_SEPARATOR) + INDEX_REDIRECT_URI;
|
||||||
response.sendRedirect(adminIndexRedirectUri);
|
response.sendRedirect(adminIndexRedirectUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package run.halo.app.conf;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.util.AntPathMatcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ant path matcher test.
|
||||||
|
*
|
||||||
|
* @author johnniang
|
||||||
|
*/
|
||||||
|
public class AntPathMatcherTest {
|
||||||
|
|
||||||
|
private final AntPathMatcher pathMatcher = new AntPathMatcher();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void matchTest() {
|
||||||
|
Assert.assertFalse(pathMatcher.match("/admin/?*/**", "/admin"));
|
||||||
|
Assert.assertFalse(pathMatcher.match("/admin/?*/**", "/admin/"));
|
||||||
|
|
||||||
|
Assert.assertTrue(pathMatcher.match("/admin/?*/**", "/admin/index.html"));
|
||||||
|
Assert.assertTrue(pathMatcher.match("/admin/?*/**", "/admin/index.html/more"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue