weirdoheheelf 5 tahun lalu
induk
melakukan
f90b6e1c86

+ 1 - 2
seecoder-portal-server/src/main/java/cn/seecoder/seecoderportalserver/web/rest/AuthController.java

@@ -27,8 +27,7 @@ public class AuthController {
     private static final Logger log = LoggerFactory.getLogger(DomainUserDetailsService.class);
 
     private static final String ALLOWED_REDIRECT_DOMAINS =
-            "([\\w.]*\\.seecoder\\.cn)" + "|" +
-            "(localhost:\\d+)";
+            ".*(([\\w.]*\\.seecoder\\.cn)|(localhost:\\d+)).*";
 
     @GetMapping("/interaction")
     public ModelAndView interaction(

+ 18 - 0
seecoder-portal-server/src/test/java/cn/seecoder/seecoderportalserver/web/rest/AuthControllerTest.java

@@ -0,0 +1,18 @@
+package cn.seecoder.seecoderportalserver.web.rest;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.regex.Pattern;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * @author kunduin
+ */
+class AuthControllerTest {
+    @Test
+    public void matchTest() {
+        assertTrue(Pattern.matches(".*(([\\w.]*\\.seecoder\\.cn)|(localhost:\\d+)).*", "http://localhost:3000"));
+        assertFalse(Pattern.matches(".*(([\\w.]*\\.seecoder\\.cn)|(localhost:\\d+)).*", "http://a:3000"));
+    }
+}