File tree Expand file tree Collapse file tree
src/main/java/com/dkaedv/glghproxy Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313public class Application extends SpringBootServletInitializer {
1414
1515 public static void main (String [] args ) {
16+ System .setProperty ("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH" , "true" );
1617 SpringApplication .run (Application .class , args );
1718 }
1819
Original file line number Diff line number Diff line change 55import org .springframework .web .bind .annotation .PathVariable ;
66import org .springframework .web .bind .annotation .RequestMapping ;
77
8+ import javax .servlet .http .HttpServletRequest ;
9+ import org .springframework .web .servlet .HandlerMapping ;
10+ import org .springframework .util .AntPathMatcher ;
11+
812@ Controller
913public class RedirectsController {
1014
@@ -38,13 +42,18 @@ public String commit(
3842 return "redirect:" + gitlabUrl + "/" + namespace + "/" + repo + "/commit/" + sha ;
3943 }
4044
41- @ RequestMapping ("/{namespace}/{repo}/tree/{branch} " )
45+ @ RequestMapping ("/{namespace}/{repo}/tree/** " )
4246 public String repoTree (
4347 @ PathVariable String namespace ,
4448 @ PathVariable String repo ,
45- @ PathVariable String branch
49+ HttpServletRequest request
50+ //@PathVariable String branch
4651 ) {
47-
52+ String path = (String ) request .getAttribute (HandlerMapping .PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE );
53+ String bestMatchPattern = (String ) request .getAttribute (HandlerMapping .BEST_MATCHING_PATTERN_ATTRIBUTE );
54+ AntPathMatcher apm = new AntPathMatcher ();
55+ String branch = apm .extractPathWithinPattern (bestMatchPattern , path );
56+
4857 return "redirect:" + gitlabUrl + "/" + namespace + "/" + repo + "/tree/" + branch ;
4958 }
5059
You can’t perform that action at this time.
0 commit comments