mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-08-28 05:25:04 +00:00
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:
parent
c5d92a24ab
commit
e7b9274190
1 changed files with 5 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue