Repository navigation
Fix regex flags being ignored in regex body matching - #215
Merged
Merged
Conversation
Member
|
Very nice, thanks @theluckystrike! Merged. By the way, in case you're not aware, HTTP Toolkit Pro is free for all contributors to all https://github.com/httptoolkit repos. If that would be useful, just let me know your email (either here or by sending a message to opensource @ httptoolkit.com) and I'll set you up with an account. |
Contributor
Author
|
Thanks for the quick merge, and for the Pro offer. That's kind of you. I'll get in touch if I end up needing 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
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.
withBody() with a regular expression drops the regex flags. RegexBodyMatcher only keeps regex.source and rebuilds the RegExp without flags, so a rule like .withBody(/"username": "test"/i) doesn't match a body with different casing. The rule explanation also leaves the flags out.
This keeps regex.flags next to the source and uses it when matching and in explain(), the same way RegexPathMatcher already does since 04c5320.
Added a test in body-matching.spec.ts that sends an uppercase body to the existing /gi rule. It fails on main and passes with this change. npm run build:src and npm run test:node pass locally (836 passing).