fix(onebot): unify message segment type normalization

Keep empty-placeholder detection aligned with strict segment parsing.
This commit is contained in:
DrSmoothl committed 2026-07-23 12:18:02 +08:00
1 parent edd2ac278a
commit b884a1c479
2 files changed
+22 -5

No files matched your search

@@ -148,6 +148,19 @@ describe('parseMessage', () => {
});
});
it('does not treat whitespace-padded segment types as empty text placeholders', async () => {
await expect(parseMessage(
[
{ type: 'image', data: { file: 'https://example.com/image.png' } },
{ type: ' text ', data: { text: '' } },
] as any,
false,
)).rejects.toMatchObject({
code: 'UNKNOWN_TYPE',
elementType: ' text ',
});
});
it('preserves whitespace-only text segments', async () => {
await expect(parseMessage(
[{ type: 'text', data: { text: ' ' } }] as any,