Skip to content

Commit

Permalink
Merge pull request #9 from db-ui/feat-clean-separators
Browse files Browse the repository at this point in the history
feat: handle clean separators
  • Loading branch information
nmerget authored Apr 5, 2024
2 parents 3a0f16a + c90cf28 commit 4f1ef9c
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 4f1ef9c

Please sign in to comment.