Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@
## 2024-07-13 - 빈 디렉토리 상태의 접근성(Accessibility) 개선
**Learning:** 정적 파일 서버의 빈 디렉토리 상태는 스크린 리더 사용자에게 컨텐츠 누락으로 오해받을 수 있으며, 시각적으로도 일반 리스트 아이템과 정렬이 맞지 않는 문제가 있었습니다.
**Action:** 빈 상태를 나타내는 요소에 `role="status"`를 추가하여 스크린 리더가 명확하게 인지할 수 있도록 하고, 아이콘과 flex 레이아웃을 통해 다른 리스트 아이템과 일관된 시각적 흐름을 제공하도록 합니다.

## 2026-08-05 - 루트 디렉토리 빈 이름 대체(Fallback)
**Learning:** 파일 시스템 루트 디렉토리(예: '/')의 경우 `File.getName()`이 빈 문자열을 반환합니다. 이로 인해 빈 `<title>` 및 `<h1>` 태그가 생성되어 접근성이 저하되고 스크린 리더 사용자에게 혼란을 줄 수 있습니다.
**Action:** HTML 출력에서 디렉토리 이름을 표시할 때, `getName()`이 빈 문자열인 경우 `absolutePath`를 폴백으로 사용하도록 하여 제목 및 접근성 태그 요소가 비어 있지 않게 보장하십시오.
4 changes: 2 additions & 2 deletions src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,12 @@ ${cssContent} </style>
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src '${styleHash}'; base-uri 'none'; form-action 'none';">
<!-- 보안 향상: 리퍼러를 통한 디렉토리 경로 노출 방지 -->
<meta name="referrer" content="no-referrer">
<title>${curr_dir.getName().escapeHtml()}</title>
<title>${if (curr_dir.getName().isEmpty()) curr_dir.absolutePath.escapeHtml() else curr_dir.getName().escapeHtml()}</title>
${css}
</head>
<body>
<main>
<h1>${curr_dir.getName().escapeHtml()}</h1>
<h1>${if (curr_dir.getName().isEmpty()) curr_dir.absolutePath.escapeHtml() else curr_dir.getName().escapeHtml()}</h1>
<nav aria-label="디렉토리 목록">
<ul role="list">
<li><a class="dir-link" href="./.." aria-label="상위 디렉토리로 이동" title="상위 디렉토리로 이동"><span class="icon" aria-hidden="true">&#x21B0;</span> <span>..</span></a></li>
Expand Down
20 changes: 20 additions & 0 deletions src/test/kotlin/html4tree/MainTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,26 @@ class MainTest {
process_dir(tempDir)
}

@Test
fun testProcessDirRootDirectoryNameFallback() {
// Create an anonymous File subclass to mock a root directory where getName() returns an empty string
val fakeRoot = object : File(tempDir, "fakeRoot") {
override fun getName() = ""
}
fakeRoot.mkdir()

process_dir(fakeRoot)

val indexFile = File(fakeRoot, "index.html")
assertTrue(indexFile.exists())
val htmlContent = indexFile.readText()

val expectedTitle = "<title>${fakeRoot.absolutePath.escapeHtml()}</title>"
val expectedH1 = "<h1>${fakeRoot.absolutePath.escapeHtml()}</h1>"
assertTrue(htmlContent.contains(expectedTitle), "Should fallback to absolutePath for title")
assertTrue(htmlContent.contains(expectedH1), "Should fallback to absolutePath for h1")
}

@Test(expected = IllegalArgumentException::class)
fun testGoBlankDir() {
go(" ", -1)
Expand Down
Loading