Fix Wildcard#match? matching a wildcard rule against its own value#549
Open
chatman-media wants to merge 1 commit into
Open
Fix Wildcard#match? matching a wildcard rule against its own value#549chatman-media wants to merge 1 commit into
chatman-media wants to merge 1 commit into
Conversation
A wildcard rule like *.com requires an extra label before it, but
Rule::Base#match? was chomping the value off and calling it a match
whenever the diff was empty - so match?("com") returned true for the
*.com rule, same as it would for a plain "com" rule. There's actually
a FIXME comment marking this exact case in the tests already.
Added a Wildcard#match? override that requires the extra label (i.e.
the diff must end with a dot, not just be empty), and uncommented/
extended the test case.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
*.com'smatch?should only be true for names with at least one label beforecom(that's what the wildcard is for), butRule::Base#match?treats an exact match againstvalueas a hit too, somatch?("com")for the*.comrule comes backtrue- same as a plaincomrule would. There's even a commented-out FIXME test for exactly this in rule_test.rb already.decompose/the actual parsing pipeline aren't affected since they use their own regex, butmatch?is a documented public method and gives the wrong answer if you call it directly on a wildcard rule.Added an override in
Wildcardthat requires the extra label, uncommented the FIXME'd test case and added a couple more (multi-label wildcard value, plus a dedicatedtest_matchinRuleWildcardTest).