🐛 Parse valid publicId even though the prefix is empty

This commit is contained in:
Baptiste Arnaud
2023-08-17 17:59:44 +02:00
parent 9cfca3857e
commit a4ba9a8a77
3 changed files with 6 additions and 4 deletions

View File

@@ -1,4 +1,6 @@
import { toKebabCase } from '@/helpers/toKebabCase'
export const parseDefaultPublicId = (name: string, id: string) =>
toKebabCase(name) + `-${id?.slice(-7)}`
export const parseDefaultPublicId = (name: string, id: string) => {
const prefix = toKebabCase(name)
return `${prefix !== '' ? `${prefix}-` : ''}${id?.slice(-7)}`
}