Slugify icon indicating copy to clipboard operation
Slugify copied to clipboard

Min length

Open sommmen opened this issue 1 year ago • 3 comments

Hiya,

There is a MaximumLength but could we also get minimum one? The min commercetools length of a slug is 2 chars;

https://docs.commercetools.com/api/projects/products#productdraft

Maybe a feature to add characters or something?

sommmen avatar Apr 03 '25 15:04 sommmen

What would be the expected outcome here if you try and slug something that is too short? It should throw an exception, or pad the slug out with something?

ctolkien avatar Jun 16 '25 04:06 ctolkien

I can imagine a setting for this.

  • We can throw (also nice when debugging if business logic handles this instead of the lib)
  • We can pad with a single char
  • We can use random chars (or Guid) to pad

That being said, i don't think you'd really want to pad the slug, since it could lead to duplicates easily, and would mess up SEO?

sommmen avatar Jun 16 '25 07:06 sommmen

I agree that padding is weird, and it should throw instead.

ctolkien avatar Jun 19 '25 22:06 ctolkien