From 26d494b276b0ad99a3c7092ee9e9241c8c03ee3b Mon Sep 17 00:00:00 2001 From: Kim EunSu <88280787+rladmstn@users.noreply.github.com> Date: Thu, 21 Nov 2024 20:56:25 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EB=AC=B8=EC=A0=9C=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=8B=9C=20=EC=9E=98=EB=AA=BB=EB=90=9C=20=EB=A7=81?= =?UTF-8?q?=ED=81=AC=20=EC=98=88=EC=99=B8=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#190)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat : 문제 생성 시 잘못된 링크 예외 조건 추가 * feat : parts 크기 조건 수정 --- src/main/java/com/gamzabat/algohub/constants/ApiConstants.java | 1 + .../algohub/feature/problem/service/ProblemService.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gamzabat/algohub/constants/ApiConstants.java b/src/main/java/com/gamzabat/algohub/constants/ApiConstants.java index 4eae7f40..20dd72ed 100644 --- a/src/main/java/com/gamzabat/algohub/constants/ApiConstants.java +++ b/src/main/java/com/gamzabat/algohub/constants/ApiConstants.java @@ -3,6 +3,7 @@ public final class ApiConstants { public static final String SOLVED_AC_PROBLEM_API_URL = "https://solved.ac/api/v3/problem/lookup?problemIds="; public static final String BOJ_USER_PROFILE_URL = "https://www.acmicpc.net/user/"; + public static final String BOJ_PROBLEM_URL = "www.acmicpc.net"; private ApiConstants() { throw new RuntimeException("Can not instantiate : ApiConstants"); diff --git a/src/main/java/com/gamzabat/algohub/feature/problem/service/ProblemService.java b/src/main/java/com/gamzabat/algohub/feature/problem/service/ProblemService.java index 4ff04836..54231b15 100644 --- a/src/main/java/com/gamzabat/algohub/feature/problem/service/ProblemService.java +++ b/src/main/java/com/gamzabat/algohub/feature/problem/service/ProblemService.java @@ -337,7 +337,7 @@ private String getProblemTitle(JsonNode problemDetails) { private String getProblemId(CreateProblemRequest request) { String url = request.link(); String[] parts = url.split("/"); - if (!parts[2].equals("www.acmicpc.net")) + if (parts.length < 3 || !parts[2].equals(BOJ_PROBLEM_URL)) throw new NotBojLinkException(HttpStatus.BAD_REQUEST.value(), "백준 링크가 아닙니다"); return parts[parts.length - 1]; }