Skip to content

Commit 0a81008

Browse files
moha-bekhclaude
andcommitted
Read only files, not directories, in the Library anchor check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011G2ivq9Pvdy6K3RjrQh7fW
1 parent edcc08e commit 0a81008

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/library/library.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test } from 'node:test'
22
import assert from 'node:assert/strict'
3-
import { existsSync, readFileSync } from 'node:fs'
3+
import { existsSync, readFileSync, statSync } from 'node:fs'
44
import { resolve } from 'node:path'
55
import { loadEntries, parseEntry, validateEntries, entryRoute, target, validDate } from './load.ts'
66
import { markdown } from './markdown.ts'
@@ -61,7 +61,7 @@ test('generated documents have unique IDs, working internal links and real no-JS
6161
const dest = docs.get(url.pathname)
6262
// an anchor in a generated page, or in a static file such as the icon sprite
6363
const file = resolve('public', url.pathname.slice(1))
64-
const target = dest ?? (existsSync(file) ? readFileSync(file, 'utf8') : undefined)
64+
const target = dest ?? (url.hash && existsSync(file) && statSync(file).isFile() ? readFileSync(file, 'utf8') : undefined)
6565
if (url.hash) assert.ok(target?.includes(`id="${url.hash.slice(1)}"`), `${path}: missing anchor ${href}`)
6666
else assert.ok(dest || old.has(url.pathname) || existsSync(resolve('public', url.pathname.slice(1))) || existsSync(resolve(url.pathname.slice(1))), `${path}: missing ${href}`)
6767
}

0 commit comments

Comments
 (0)