Fixed layout toLowerCase bug (#2770)

This commit is contained in:
Alexandr Garbuzov 2023-06-05 13:10:22 +03:00 committed by GitHub
parent 1a2a82c3be
commit 98b047751e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -44,6 +44,16 @@ export default async (req, res) => {
return res.send(renderError("Something went wrong", "Locale not found"));
}
if (
layout !== undefined &&
(typeof layout !== "string" ||
!["compact", "normal", "donut", "donut-vertical", "pie"].includes(layout))
) {
return res.send(
renderError("Something went wrong", "Incorrect layout input"),
);
}
try {
const topLangs = await fetchTopLanguages(
username,

View file

@ -746,7 +746,7 @@ const renderTopLanguages = (topLangs, options = {}) => {
totalLanguageSize,
hide_progress,
);
} else if (layout?.toLowerCase() === "donut") {
} else if (layout === "donut") {
height = calculateDonutLayoutHeight(langs.length);
width = width + 50; // padding
finalLayout = renderDonutLayout(langs, width, totalLanguageSize);