This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
Improve handling of digits in CamelCaseToSeparator filter #45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to add the behaviour asked in #33
Since the reason behind using the CamelCaseSeparator is tokenizing strings when case is changed, usual expectation is beginning a new token when hitting a number or digit.
I will try to summarize both current and changed behaviour on numbers with some examples:
The issue #33 is about the
CamelCaseToDashFilter
but since it derived fromCamelCaseToSeparator
likeCamelCaseToUnderscore
, this change will affect both childs ofCamelCaseToSeparator
. For this reason, I also added more tests toCamelCaseToDashTest
.After digging dozen of approaches including other platforms such as Java and C# I came up with this final patterns with positive lookbehind and lookaheads. (Achieving same effect with a single regex seems like impossible, at least I give up)
I'm also aware of changing an existing test is not a good practice. Since the expected behaviour is changed for digits, I forced into touching the
CamelCaseToUnderscoreTest
:Altering the
CamelCaseToUnderscoreTest
seems like mandatory if the desired behaviour will be changed.All tests are still green.