Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

437 B
Raw Blame
/**
 * Mirrors ActiveSupport's `String#parameterize`: lowercase, ASCII-friendly,
 * hyphen-separated. Keeps a code preview in step with what `normalizes :code`
 * produces on the model, so an operator sees the final slug as they type.
 */
export function slugify(value: string): string {
  return value
    .normalize('NFKD')
    .replace(/\p{M}/gu, '')
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, '-')
    .replace(/^-+|-+$/g, '')
}