Skip to content

Commit

Permalink
Fixed layout toLowerCase bug (anuraghazra#2770)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 authored and jacobbexten committed Nov 6, 2024
1 parent a07e46c commit 6668daa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions api/top-langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/cards/top-languages-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6668daa

Please sign in to comment.