diff --git a/api/index.js b/api/index.js index 94f734cf..6e254075 100644 --- a/api/index.js +++ b/api/index.js @@ -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, diff --git a/src/utils.js b/src/utils.js index b6b74f5a..48b28116 100644 --- a/src/utils.js +++ b/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, };