-
Notifications
You must be signed in to change notification settings - Fork 250
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
Ease extension of Slugify class #44
Ease extension of Slugify class #44
Conversation
First you should split this up into two Pull Requests. These are completely different things. I will merge the PR to change the visibility of the properties, but I don't think it is useful to change the interface of |
You are right, this should be split into two pull requests. I'll do it right away. |
Done, just removed the last commit and pushed it again (with --force) |
Ease extension of Slugify class
Regarding the regular expression. If there is need to modify it, there should be another way than supplying another parameter to |
Yes, I like the idea of using a property. A protected property could be overriden, but maybe a setter would be good too. |
Yes, please make another PR. Thanks. |
I made a few minor changes.
Changed the visibility of rules and rulesets properties to protected to allow them to be overriden or used in child classes while extending Slugify.
Maybe using a getter for the rules property would do the same job, but this was my approach.
Added a third optional param to the
slufigy
method with the regular expression to be applied to the string.I made this because I needed to allow other characters in the slug, like dots for filenames. I didn't want
My Cool File.zip
to becomemy-cool-file-zip
butmy-cool-file.zip
.I wasn't sure if that argument should be set in the constructor or in this method, but I think this is good enough.
I was thinking also on giving the option to define if the string should be lowered or not, but I'm not sure what's the best way to do that.