Improve artwork edit form
This commit is contained in:
24
src/utils/artworkHelpers.ts
Normal file
24
src/utils/artworkHelpers.ts
Normal file
@ -0,0 +1,24 @@
|
||||
export function slugify(input: string) {
|
||||
return input
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/['"]/g, "")
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/(^-|-$)+/g, "");
|
||||
}
|
||||
|
||||
export function normalizeNames(items?: string[]) {
|
||||
const out: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
for (const raw of items ?? []) {
|
||||
const name = raw.trim().replace(/\s+/g, " ");
|
||||
if (!name) continue;
|
||||
const key = name.toLowerCase();
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
out.push(name);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user