Skip to content
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

Added regex support to the withBody matcher #26

Merged
merged 7 commits into from Apr 26, 2019

Conversation

Projects
None yet
2 participants
@pimterry
Copy link
Member

commented Apr 26, 2019

(Originally by @gdmerm, this continues where #25 left off)

We have a need to match a request body based on regular expressions syntax. Instead of modifying the existing withBody matcher, I have created a new matcher and assigned it to a withRegexBody handler, in order to mitigate for any risk in breaking the existing withBody functionality.

I have tried to follow your code patterns and naming conventions but obviously I may have slipped somewhere. Let me know what you think!

@pimterry

This comment has been minimized.

Copy link
Member Author

commented Apr 26, 2019

Whew, sorted.

I've made a few changes on top of this, as separate commits just in case you're interested. I've combined the two matchers into a single withBody matcher with different behaviour depending on the type of the argument (string or regex). You did say you were cautious about the risk of breaking the existing matcher, but I think your implementation & the tests all look good, it should be pretty safe.

There was one bug that I've quickly fixed, which was failing the tests. That's because the string in the type field of the matcher needs to match the string key in the MatcherDataLookup, which is used in browser usage to build a rule from data when sending it from the client to the server. Just needed the string updating, now it's all good.

I'll merge once the tests pass, and put a release out later today with this included.

@pimterry pimterry merged commit eefa899 into master Apr 26, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@pimterry pimterry deleted the withRegexBody branch Apr 26, 2019

@gdmerm

This comment has been minimized.

Copy link

commented Apr 26, 2019

@pimterry

This comment has been minimized.

Copy link
Member Author

commented Apr 26, 2019

No worries! Thanks for contributing 👍. This has now been published, v0.14.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.