Skip to content
This repository has been archived by the owner on Feb 14, 2025. It is now read-only.

Commit

Permalink
feat: handle clean separators
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget committed Apr 4, 2024
1 parent 3a0f16a commit c90cf28
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/figma-icon-exporter/download-icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 (
Expand All @@ -42,7 +45,7 @@ export const downloadIcons = async ({
}
} else {
iconName = cleanSymbols(
iconName.toLowerCase().trim().replaceAll(" ", "_"),
(iconName = overwriteSeperator(iconName.toLowerCase(), "_")),
);
}

Expand Down

0 comments on commit c90cf28

Please sign in to comment.