Commit 5fce46d6 authored by anuraghazra's avatar anuraghazra
Browse files

fix: query param booleans

parent 00ce9d37
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
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 −0
Original line number Diff line number Diff line
@@ -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,
};