Skip to content

Fix regex flags being ignored in regex body matching - #215

Merged
pimterry merged 1 commit into
httptoolkit:mainfrom
theluckystrike:fix/mockttp-payer-proof
Oct 6, 2026
Merged

pimterry merged 1 commit into
httptoolkit:mainfrom
theluckystrike:fix/mockttp-payer-proof

Conversation

@theluckystrike

Copy link
Copy Markdown
Contributor

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).

@CLAassistant

CLAassistant commented Oct 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pimterry
pimterry merged commit e352313 into httptoolkit:main Oct 6, 2026
10 checks passed
@pimterry

pimterry commented Oct 6, 2026

Copy link
Copy Markdown
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.

@theluckystrike

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants