diff --git a/api/top-langs.js b/api/top-langs.js index acb2da0754c7c..f57ecfb3cfae0 100644 --- a/api/top-langs.js +++ b/api/top-langs.js @@ -45,6 +45,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, diff --git a/src/cards/top-languages-card.js b/src/cards/top-languages-card.js index 92f5b9d92d9e1..23c76bc81fa95 100644 --- a/src/cards/top-languages-card.js +++ b/src/cards/top-languages-card.js @@ -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);