Skip to content

Commit

Permalink
feat : 문제 생성 시 잘못된 링크 예외 조건 추가 (#190)
Browse files Browse the repository at this point in the history
* feat : 문제 생성 시 잘못된 링크 예외 조건 추가

* feat : parts 크기 조건 수정
  • Loading branch information
rladmstn authored Nov 21, 2024
1 parent c855b7b commit 26d494b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit 26d494b

Please sign in to comment.