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 LucienZhang committed Jun 5, 2023
1 parent fc9b9a3 commit f9e6e0c
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 @@ -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,
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 f9e6e0c

Please sign in to comment.