You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This allows preserve option, which will preserve specified characters both when using strict mode and not.
It allows for different structures, like test_property and test.property being valid. Another example is having more complex paths: path.to.property_name.
As implemented here, there's nothing enforcing that the elements of preserve are a single character, so lots of things can be passed that will result in weird bugs because they won't be escaped properly or whatever. This is especially true given that an option like this is bound to be used for special regex characters like [ and ]. Would it make sense to throw an error if the user passes an array containing strings of length greater than one? Or maybe it makes sense to have the user pass in a single string containing all the characters to be preserved rather than an array of single characters? Then you can split() it into an array of single-character strings? There might be surprising bugs still lurking in such an approach, but it seems less of a footgun for users than the current implementation.
It's all but certain that someone will pass ['/%*'] rather than ['/', '%', '*'] and I think we should throw an error if someone does that (either because each element should have a length of 1 or because we write the API to expect a string and not an array of characters).
As an example of some weirdness that we'll want to guard against:
Using preserve: [''] results in a SyntaxError. We should provide an error telling the person that they can't preserve an empty string or something like that.
Using preserve: ['.]'] preserves /, _, etc. That will be a very surprising result to whoever runs across it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 allows
preserveoption, which will preserve specified characters both when using strict mode and not.It allows for different structures, like
test_propertyandtest.propertybeing valid. Another example is having more complex paths:path.to.property_name.I think this eloquently fixes #131 as well.
Does not affect current implementation in any way so shouldn't be a breaking change.