mirror of
https://github.com/anuraghazra/github-readme-stats.git
synced 2024-12-15 06:04:17 +08:00
fix: query param booleans
This commit is contained in:
parent
00ce9d37d2
commit
5fce46d67c
@ -1,5 +1,5 @@
|
||||
require("dotenv").config();
|
||||
const { renderError } = require("../src/utils");
|
||||
const { renderError, parseBoolean } = require("../src/utils");
|
||||
const fetchStats = require("../src/fetchStats");
|
||||
const renderStatsCard = require("../src/renderStatsCard");
|
||||
|
||||
@ -30,9 +30,9 @@ module.exports = async (req, res) => {
|
||||
res.send(
|
||||
renderStatsCard(stats, {
|
||||
hide: JSON.parse(hide || "[]"),
|
||||
show_icons,
|
||||
hide_border,
|
||||
hide_rank,
|
||||
show_icons: parseBoolean(show_icons),
|
||||
hide_border: parseBoolean(hide_border),
|
||||
hide_rank: parseBoolean(hide_rank),
|
||||
line_height,
|
||||
title_color,
|
||||
icon_color,
|
||||
|
11
src/utils.js
11
src/utils.js
@ -33,6 +33,16 @@ function isValidHexColor(hexColor) {
|
||||
).test(hexColor);
|
||||
}
|
||||
|
||||
function parseBoolean(value) {
|
||||
if (value === "true") {
|
||||
return true;
|
||||
} else if (value === "false") {
|
||||
return false;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
function request(data, headers) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios({
|
||||
@ -54,4 +64,5 @@ module.exports = {
|
||||
encodeHTML,
|
||||
isValidHexColor,
|
||||
request,
|
||||
parseBoolean,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user