Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally prevent the removal of the delimeter at the beginning and end. #34

Open
e-spin opened this issue May 16, 2023 · 6 comments
Open

Comments

@e-spin
Copy link

e-spin commented May 16, 2023

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]

@Rumi-Aguirre
Copy link

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

@ausi
Copy link
Owner

ausi commented Aug 25, 2023

@Rumi-Aguirre can you describe your use case in detail? Maybe with some examples?

@Rumi-Aguirre
Copy link

Rumi-Aguirre commented Aug 25, 2023

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 "-"

@ausi
Copy link
Owner

ausi commented Aug 25, 2023

"_sugiartoss_" -> "sugiartoss-"

so the behavior in the beginning of the string should be different than at the end of the string?

@Rumi-Aguirre
Copy link

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.

@Rumi-Aguirre
Copy link

I've made a PR to solve this scenario. It would be great if you can check it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants