fix: author is not iterable (#11555)
Co-authored-by: xianjiantao <xianjiantao@bytedance.com>
This commit is contained in:
parent
e455abe486
commit
728da7f154
|
|
@ -66,7 +66,7 @@ module.exports = async (ctx, next) => {
|
|||
|
||||
if (typeof item.author === 'string') {
|
||||
item.author = collapseWhitespace(item.author);
|
||||
} else if (typeof item.author === 'object') {
|
||||
} else if (typeof item.author === 'object' && item.author !== null) {
|
||||
for (const a of item.author) {
|
||||
a.name = collapseWhitespace(a.name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,6 +214,12 @@ module.exports = async (ctx) => {
|
|||
enclosure_type: 'image/jpeg',
|
||||
enclosure_length: 3661,
|
||||
itunes_duration: 36610,
|
||||
},
|
||||
{
|
||||
title: 'Title4 author is null',
|
||||
pubDate: new Date(`2019-3-1`).toUTCString(),
|
||||
link: `https://github.com/DIYgod/RSSHub/pull/11555`,
|
||||
author: null,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ describe('template', () => {
|
|||
const parsed = await parser.parseString(response.text);
|
||||
expect(parsed.items[2].author).toBe(['DIYgod1', 'DIYgod2'].map((name) => name).join(', '));
|
||||
expect(parsed.items[3].author).toBe(['DIYgod3', 'DIYgod4', 'DIYgod5'].map((name) => name).join(', '));
|
||||
expect(parsed.items[4].author).toBeUndefined();
|
||||
});
|
||||
|
||||
it(`long title`, async () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue