🔨 fix user contribution parsing

This commit is contained in:
platane
2020-10-29 20:35:28 +01:00
parent d6c79a0e47
commit 1c6814c2fa

View File

@@ -27,8 +27,9 @@ const parseUserPage = (content: string) => {
o,
(x) => x.attr && x.attr.class && x.attr.class.trim() === "legend"
);
const colorScheme = legend.li.map(
(x: any) => x.attr.style.match(/background\-color: +(#\w+)/)![1]!
(x: any) => x.attr.style.match(/background\-color: +(.+)/)![1]!
);
//
@@ -53,7 +54,12 @@ const parseUserPage = (content: string) => {
)
.flat();
return { cells, colorScheme };
return {
cells,
colorScheme: colorScheme.every((c: string) => c.startsWith("#"))
? colorScheme
: ["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"],
};
};
/**