diff --git a/scripts/lib-franklin.js b/scripts/lib-franklin.js index 9a45d90..5ac82c2 100644 --- a/scripts/lib-franklin.js +++ b/scripts/lib-franklin.js @@ -99,7 +99,8 @@ export function loadCSS(href, callback) { */ export function getMetadata(name) { const attr = name && name.includes(':') ? 'property' : 'name'; - const meta = [...document.head.querySelectorAll(`meta[${attr}="${name}"]`)].map((m) => m.content).join(', '); + const meta = [...document.head.querySelectorAll(`meta[${attr}="${name}"]`)] + .map((m) => m.content).join(', '); return meta || ''; } @@ -114,7 +115,7 @@ export function toClassName(name) { : ''; } -/* +/** * Sanitizes a name for use as a js property name. * @param {string} name The unsanitized name * @returns {string} The camelCased name @@ -123,6 +124,46 @@ export function toCamelCase(name) { return toClassName(name).replace(/-([a-z])/g, (g) => g[1].toUpperCase()); } +/** + * Sanitize the svg text code + * @param {string} svg - raw svg code + * @param {string} iconName + * @returns {string} sanitized svg string + */ +function cleanSVG(svg, iconName) { + if (svg.match(/