Open ntbm opened 1 year ago
Hi @ntbm - thanks for this!
The failing test is an interesting one... normally the lib won't leave trailing -'s but we are specifically asking for a max length....
The failing test is an interesting one... normally the lib won't leave trailing -'s but we are specifically afking for a max length....
That's why I added it. Handling all the specific edgescases will be a nightmare. So I'd vote to just accept that edge case. Question is if it be best to document it 🤔
Would it make sense to make the limiting a bit “smarter” so that it would not break within words if possible?
For example "this is an example"
would slugify to "this-is-an-example"
. But cutting it at 15 characters would result in "this-is-an-exam"
which might not be ideal. Instead, there could be some more sophisticated limiting approach which would result in "this-is-an"
instead since example
doesn’t fit anymore.
Would it make sense to make the limiting a bit “smarter” so that it would not break within words if possible?
If there is a fast way of doing that? I imagine you need scan back to find the last non - character within the string limit length.
Implements #18
Added Option to Limit Output Slug Length. Default Value is null to not introduce any breaking Changes into the Library.