mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-23 07:51:18 +01:00
Handle edge case when no chara chunk
This commit is contained in:
parent
84a21fba27
commit
19c3b3016c
@ -18,12 +18,17 @@ const parse = async (cardUrl, format) => {
|
||||
});
|
||||
|
||||
if (textChunks.length === 0) {
|
||||
console.error('PNG metadata does not contain any character data.');
|
||||
console.error('PNG metadata does not contain any text chunks.');
|
||||
throw new Error('No PNG metadata.');
|
||||
}
|
||||
|
||||
let index = textChunks.findIndex((chunk) => chunk.keyword.toLowerCase() == 'chara');
|
||||
|
||||
if (index === -1) {
|
||||
console.error('PNG metadata does not contain any character data.');
|
||||
throw new Error('No PNG metadata.');
|
||||
}
|
||||
|
||||
return Buffer.from(textChunks[index].text, 'base64').toString('utf8');
|
||||
}
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user