🛠️ Improve parseSvgFilename to support firstUpperCase option for component naming
📦 Build / 🛠️ Build app (push) Has been cancelled
🧑‍🚀 Check / ⚙️ Linting (push) Has been cancelled
🧑‍🚀 Check / 📦 SVGs Size (push) Has been cancelled

This commit is contained in:
pheralb
2025-08-31 16:35:30 +01:00
parent 4cd2c84273
commit 55199765be
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -1,15 +1,18 @@
interface ParseSvgFilename {
file: string;
log?: boolean;
firstUpperCase?: boolean;
}
export const parseSvgFilename = (params: ParseSvgFilename): string => {
const { file, log } = params;
const { file, log, firstUpperCase = false } = params;
const name = file.replace(/\.svg$/i, "");
let component = name
.replace(/[-_\s]+(.)?/g, (_, char) => (char ? char.toUpperCase() : ""))
.replace(/^(.)/, (char) => char.toLowerCase());
.replace(/^(.)/, (char) =>
firstUpperCase ? char.toUpperCase() : char.toLowerCase(),
);
if (/^\d/.test(component)) {
if (log) {