mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-02 20:36:49 +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) {
|
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.');
|
throw new Error('No PNG metadata.');
|
||||||
}
|
}
|
||||||
|
|
||||||
let index = textChunks.findIndex((chunk) => chunk.keyword.toLowerCase() == 'chara');
|
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');
|
return Buffer.from(textChunks[index].text, 'base64').toString('utf8');
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user