dgilland / pydash

The kitchen sink of Python utility libraries for doing "stuff" in a functional way. Based on the Lo-Dash Javascript library.
http://pydash.readthedocs.io
MIT License
1.32k stars 93 forks source link

slugify behavior with single quotes #190

Closed caiolopes closed 1 year ago

caiolopes commented 1 year ago

Hey, just noticed a behavior that not sure if it is always wanted, so opening this issue to discuss.

How single quoted is handled by pydash slugify function.

In comparison with a widely used slugify specific library: https://github.com/un33k/python-slugify, we have the following difference:

In [1]: import pydash

In [2]: from slugify import slugify

In [3]: print(pydash.slugify("saint peter's university"))
saint-peter's-university

In [4]: print(slugify("saint-peter's"))
saint-peter-s-university

But, using npm slugify package, we have the same result:

> var slugify = require('slugify')
undefined
> slugify("saint peter's university")
"saint-peter's-university"

I would say that replacing single quote by the separator can be desired in some cases where we want to slugify a string, but that is a backward incompatible change for this function, so maybe adding as an optional parameter to handle those cases in the slugify function can be a option?

Of course we can call slugify and then replace manually afterwards but it would be more elegant and straightforward if handled by the library as well, idk.

dgilland commented 1 year ago

I think the single quotes should be removed so that it's "saint-peters-university".

Breaking change is ok here since there's a major release coming up.