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