Commit 2812ce0f authored by anuraghazra's avatar anuraghazra
Browse files

fix: weird unicode char

parent f9b14c94
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
const { kFormatter, getCardColors, FlexLayout } = require("../src/utils");
const {
  kFormatter,
  getCardColors,
  FlexLayout,
  encodeHTML,
} = require("../src/utils");
const getStyles = require("./getStyles");
const icons = require("./icons");

@@ -128,7 +133,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
  const apostrophe = ["x", "s"].includes(name.slice(-1)) ? "" : "s";
  const title = hide_title
    ? ""
    : `<text x="25" y="35" class="header">${name}'${apostrophe} GitHub Stats</text>`;
    : `<text x="25" y="35" class="header">${encodeHTML(name)}'${apostrophe} GitHub Stats</text>`;

  const border = `
    <rect 
+5 −3
Original line number Diff line number Diff line
@@ -17,9 +17,11 @@ const renderError = (message) => {

// https://stackoverflow.com/a/48073476/10629172
function encodeHTML(str) {
  return str.replace(/[\u00A0-\u9999<>&](?!#)/gim, function (i) {
  return str
    .replace(/[\u00A0-\u9999<>&](?!#)/gim, (i) => {
      return "&#" + i.charCodeAt(0) + ";";
  });
    })
    .replace(/\u0008/gim, "");
}

function kFormatter(num) {