fix(id3v2): prevent crash when no tag frames present
Fix TypeError: Cannot read properties of undefined (reading 'filter') by defaulting missing frame/tag collections to empty arrays/objects. - Add MP3 sample without tags + regression test - Update related TS configs and dependencies/lockfile
This commit is contained in:
@@ -104,7 +104,7 @@ export class ID3v2Parser {
|
||||
await (id3Header.flags.isExtendedHeader ? this.parseExtendedHeader() : this.parseId3Data(id3Header.size));
|
||||
|
||||
// Post process
|
||||
const chapters = ID3v2Parser.mapId3v2Chapters(this.metadata.native[this.headerType], this.metadata.format.sampleRate);
|
||||
const chapters = ID3v2Parser.mapId3v2Chapters(this.metadata.native[this.headerType]);
|
||||
this.metadata.setFormat('chapters', chapters);
|
||||
}
|
||||
|
||||
@@ -178,10 +178,9 @@ export class ID3v2Parser {
|
||||
* This function expects the `native` tags already to contain parsed `CHAP` and `CTOC` frame values,
|
||||
* as produced by `FrameParser.readData`.
|
||||
*/
|
||||
private static mapId3v2Chapters(
|
||||
id3Tags: ITag[],
|
||||
sampleRate?: number
|
||||
): IChapter[] | undefined {
|
||||
private static mapId3v2Chapters(id3Tags?: ITag[]): IChapter[] | undefined {
|
||||
|
||||
if (!id3Tags) return;
|
||||
|
||||
const chapFrames = id3Tags.filter(t => t.id === 'CHAP') as any[] | undefined;
|
||||
if (!chapFrames?.length) return;
|
||||
|
||||
Reference in New Issue
Block a user