mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 11:04:00 +00:00
Make viscolor parsing more permissive
This commit is contained in:
parent
0d29ffe3f4
commit
5ebd8f2be1
2 changed files with 36 additions and 2 deletions
|
|
@ -114,7 +114,8 @@ describe("parseViscolors", () => {
|
|||
];
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
it.only("can parse a malformed viscolors file", () => {
|
||||
|
||||
it("can parse a malformed viscolors file", () => {
|
||||
// From https://skins.webamp.org/skin/018ddb394f2bfe49efa70bce27b71cb2/Centra_CSS-102_104-3.wsz/
|
||||
const viscolors = fixture("CENTRA_VISCOLOR.TXT");
|
||||
const actual = parseViscolors(viscolors);
|
||||
|
|
@ -149,6 +150,39 @@ describe("parseViscolors", () => {
|
|||
];
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it("does not require commas to separate values", () => {
|
||||
// From https://skins.webamp.org/skin/99c6227d8880e00813a9aa6c4e808c37/valgaav_by_dreamcass-d85bqwp.wsz/
|
||||
const viscolors = fixture("viscolor_valgaav.txt");
|
||||
const actual = parseViscolors(viscolors);
|
||||
const expected = [
|
||||
"rgb(98,111,123)", // color 0 = background
|
||||
"rgb(98,111,123)", // color 1 = dots
|
||||
"rgb(21,21,21)", // 2 = top of spec
|
||||
"rgb(223,176,176)", // 16
|
||||
"rgb(218,168,168)", // 15
|
||||
"rgb(211,158,158)", // 14
|
||||
"rgb(204,147,147)", // 13
|
||||
"rgb(198,137,137)", // 12
|
||||
"rgb(191,127,127)", // 11
|
||||
"rgb(185,117,117)", // 10
|
||||
"rgb(178,107,107)", // 9
|
||||
"rgb(172,97,97)", // 8
|
||||
"rgb(165,86,86)", // 7
|
||||
"rgb(158,76,76)", // 6
|
||||
"rgb(152,66,66)", // 5
|
||||
"rgb(145,56,56)", // 4
|
||||
"rgb(138,46,46)", // 3
|
||||
"rgb(138,46,46)", // 17 = bottom of spec
|
||||
"rgb(138,46,46)", // 18 = osc 1
|
||||
"rgb(158,76,76)", // 19 = osc 2
|
||||
"rgb(178,107,107)", // 20 = osc 3
|
||||
"rgb(198,137,137)", // 21 = osc4
|
||||
"rgb(218,168,168)", // 22 = osc5
|
||||
"rgb(223,176,176)" // 23 = analyzer peak dots
|
||||
];
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseIni", () => {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ export const getFileExtension = (fileName: string): string | null => {
|
|||
|
||||
export const parseViscolors = (text: string): string[] => {
|
||||
const entries = text.split("\n");
|
||||
const regex = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/;
|
||||
const regex = /^\s*(\d+)\s*,?\s*(\d+)\s*,?\s*(\d+)/;
|
||||
const colors = [...DEFAULT_SKIN.colors];
|
||||
entries
|
||||
.map(line => regex.exec(line))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue