From c90cf28305b178442086193fb7945a346b147e46 Mon Sep 17 00:00:00 2001 From: NicolasMerget Date: Thu, 4 Apr 2024 16:31:57 +0200 Subject: [PATCH] feat: handle clean separators --- src/figma-icon-exporter/download-icons/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/figma-icon-exporter/download-icons/index.ts b/src/figma-icon-exporter/download-icons/index.ts index 18cfd07..bd8e0b7 100644 --- a/src/figma-icon-exporter/download-icons/index.ts +++ b/src/figma-icon-exporter/download-icons/index.ts @@ -5,6 +5,9 @@ import axios from "axios"; const cleanSymbols = (iconName: string): string => iconName.replaceAll("&", "and").replaceAll("/", "or"); +const overwriteSeperator = (iconName: string, separator: string): string => + iconName.trim().replaceAll("-", separator).replaceAll(" ", separator); + export const downloadIcons = async ({ icon, resolvedImages, @@ -29,9 +32,9 @@ export const downloadIcons = async ({ } if (iconNameConfig.separator) { - iconName = iconName.trim().replaceAll(" ", iconNameConfig.separator); + iconName = overwriteSeperator(iconName, iconNameConfig.separator); } else { - iconName = iconName.trim().replaceAll(" ", "_"); + iconName = overwriteSeperator(iconName, "_"); } if ( @@ -42,7 +45,7 @@ export const downloadIcons = async ({ } } else { iconName = cleanSymbols( - iconName.toLowerCase().trim().replaceAll(" ", "_"), + (iconName = overwriteSeperator(iconName.toLowerCase(), "_")), ); }