Optionally prevent the removal of the delimeter at the beginning and end.
e-spin opened this issue · 6 comments
Currently, the delimeter is removed at the beginning and end of a string. However, there are usecases where this is not desired, e.g. when only parts of a string are converted.
perhaps one could include a parameter like
['reciveDelimiter' => true]
Any progress on this? it would be very nice to have this option. I really need it. The capability to override method replaceWithDelimiter
(and others really) could be cool too, in order to allow extensibility of library
@Rumi-Aguirre can you describe your use case in detail? Maybe with some examples?
Sure!
I'm currently centralizing the logic of slug making and it must be backward compatible and I found the requirement that not allowed chars at the end of the input must be replaced by delimiter char but not trimmed. Some examples (input -> slug expected):
"sugiartoss_" -> "sugiartoss-"
"_sugiartoss_" -> "sugiartoss-"
"_sugiartoss-" -> "sugiartoss-"
assuming that delimiter is a dash "-"
"_sugiartoss_" -> "sugiartoss-"
so the behavior in the beginning of the string should be different than at the end of the string?
In this particular example I want to remove from begining but keep at the end but It would be nice if this behavior can be configured the same way that options like "delimiter" or "validChars". So can decide if want to trim the char just from beginning, from the end, from both or none to cover all use cases.
I've made a PR to solve this scenario. It would be great if you can check it :D