Skip to content

Commit

Permalink
refactor(plugins/tidy-css): replace forEach() with map()
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed May 23, 2022
1 parent a248a34 commit 33e0a1a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/plugins/tidy-css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,18 @@ async function plugin(server) {
*/
if (styleRule.style["font-family"]) {
const fonts = styleRule.style["font-family"].split(",");
const parsedFonts = [];

fonts.forEach((font) => {
const parsedFonts = fonts.map((font) => {
if (/[^a-zA-Z-]+/.test(font.trim())) {
parsedFonts.push(
// Stop escaping of <style> elements and code injection
cssEsc(font.replace(/<\/style>/gm, "").trim(), {
// Stop escaping of <style> elements and code injection
return cssEsc(
font.replace(/<\/style>/gm, "").trim(),
{
quotes: "double",
wrap: true,
})
}
);
} else {
parsedFonts.push(font.trim());
}
return font.trim();
});

styleRule.style.setProperty(
Expand Down

0 comments on commit 33e0a1a

Please sign in to comment.