fix(stat): return text/markdown for .md files regardless of OS mime registry (#433)

On macOS, mimetypes.guess_type() may not recognize .md files, causing
stat to report application/octet-stream and breaking test assertions.
Explicitly map .md files to text/markdown so the behavior is stable
across platforms.
This commit is contained in:
lichen2015 2026-08-07 16:31:03 +08:00 committed by GitHub
parent c5d92a24ab
commit e7b9274190
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -64,8 +64,11 @@ class StatStep(BaseStep):
}
if target.is_file():
payload["size"] = st.st_size
payload["mime"] = mimetypes.guess_type(target.name)[0] or "application/octet-stream"
if target.suffix == ".md":
is_md = target.suffix.lower() == ".md"
payload["mime"] = (
"text/markdown" if is_md else (mimetypes.guess_type(target.name)[0] or "application/octet-stream")
)
if is_md:
try:
meta = dict(frontmatter.loads(target.read_text(encoding="utf-8")).metadata)
except Exception: