fix(onebot): unify message segment type normalization
Keep empty-placeholder detection aligned with strict segment parsing.
This commit is contained in:
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,
|
||||
|
||||
Reference in new issue
Block a user