Skip to content

Commit

Permalink
Ignore case when parsing FLAC tags
Browse files Browse the repository at this point in the history
  • Loading branch information
aadsm authored Feb 22, 2021
1 parent d224da3 commit 4bf2436
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FLACTagReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class FLACTagReader extends MediaTagReader {
let s = data.getStringWithCharsetAt(dataOffset + 4, dataLength, "utf-8").toString();
let d = s.indexOf("=");
let split = [s.slice(0, d), s.slice(d + 1)];
switch (split[0]) {
switch (split[0].toUpperCase()) {
case "TITLE":
title = split[1];
break;
Expand Down
21 changes: 21 additions & 0 deletions src/__tests__/FLACTagReader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ describe("FLACTagReader", function() {
expect(tags.picture).toBeTruthy();
});
});

it("reads tags no matter their case", function () {
var flacFileContents = new FLACTagContents([FLACTagContents.createCommentBlock(
["Title", "A Title"],
["artist", "An Artist"],
)]);
mediaFileReader = new ArrayFileReader(flacFileContents.toArray());
tagReader = new FLACTagReader(mediaFileReader);
return new Promise(function (resolve, reject) {
tagReader.read({
onSuccess: resolve,
onFailure: reject
});
jest.runAllTimers();
}).then(function (tag) {
var tags = tag.tags;
expect(tags.title).toBeTruthy();
expect(tags.artist).toBeTruthy();
});
});

it("calls failure callback if file doesn't have comments", function() {
var flacFileEmpty = new FLACTagContents();
var fileReaderEmpty = new ArrayFileReader(flacFileEmpty.toArray());
Expand Down

0 comments on commit 4bf2436

Please sign in to comment.