Skip to content

Commit 0468dcf

Browse files
committed
fix: 중간 빌 셀이 있는 경우 정상적으로 저장이 되지 않던 문제 수정
1 parent 0411646 commit 0468dcf

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/main/java/com/example/solidconnection/common/util/MarkdownTableParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ private void validate(String[] lines) {
3030
}
3131

3232
private List<String> parseRow(String line) {
33-
return Arrays.stream(line.split("\\|"))
33+
String stripped = line.trim();
34+
if (stripped.startsWith("|")) stripped = stripped.substring(1);
35+
if (stripped.endsWith("|")) stripped = stripped.substring(0, stripped.length() - 1);
36+
return Arrays.stream(stripped.split("\\|"))
3437
.map(String::trim)
35-
.filter(s -> !s.isEmpty())
3638
.collect(Collectors.toList());
3739
}
3840

src/test/java/com/example/solidconnection/common/util/MarkdownTableParserTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ class 정상_파싱 {
4040
.doesNotContainKey("TOEIC");
4141
}
4242

43+
@Test
44+
void 중간_빈_셀이_있어도_이후_컬럼이_올바르게_매핑된다() {
45+
String markdown = """
46+
| 대학명 | 인원 | TOEIC |
47+
|--------|------|-------|
48+
| MIT | | 800 |
49+
""";
50+
51+
List<Map<String, String>> rows = parser.parse(markdown);
52+
53+
assertThat(rows.get(0))
54+
.containsEntry("대학명", "MIT")
55+
.doesNotContainKey("인원")
56+
.containsEntry("TOEIC", "800");
57+
}
58+
4359
@Test
4460
void 빈_셀은_결과_맵에_포함되지_않는다() {
4561
String markdown = """

0 commit comments

Comments
 (0)