diff --git a/src/renderStatsCard.js b/src/renderStatsCard.js index 85f5b77..7e9d0cb 100644 --- a/src/renderStatsCard.js +++ b/src/renderStatsCard.js @@ -1,4 +1,9 @@ -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 ? "" - : `${name}'${apostrophe} GitHub Stats`; + : `${encodeHTML(name)}'${apostrophe} GitHub Stats`; const border = ` { // https://stackoverflow.com/a/48073476/10629172 function encodeHTML(str) { - return str.replace(/[\u00A0-\u9999<>&](?!#)/gim, function (i) { - return "&#" + i.charCodeAt(0) + ";"; - }); + return str + .replace(/[\u00A0-\u9999<>&](?!#)/gim, (i) => { + return "&#" + i.charCodeAt(0) + ";"; + }) + .replace(/\u0008/gim, ""); } function kFormatter(num) {