Skip to content

Add Regex skipPath/skipDomain to Builder, fixes #1236 #1242

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

Merged
merged 10 commits into from
Jul 16, 2024
Merged

Add Regex skipPath/skipDomain to Builder, fixes #1236 #1242

merged 10 commits into from
Jul 16, 2024

Conversation

VenomVendor
Copy link
Contributor

📷 Screenshots

When .skipPaths(".*(jpg|jpeg|png|gif|webp|svg|bmp|ico)$".toRegex()) is set

filter-image.mp4

When .skipDomain(".*akamai.com".toRegex(), "httpbin.org".toRegex()) is set

filter-domain.mp4

📄 Context

Fixes #1236

📝 Changes

  • Added two new functions to Builder
    • skipPath(...Regex)
    • skipDomain(...Regex)

🛠️ How to test

Check commmit eaff3e1, and uncomment skipPath and/or skipDomain as needed.

Skip domian and/path when matches with regex
Fixes #1236
Moved tests
Code clean up
To ensure tests are properly tested, check for no transaction before expecting new one
Added autogenerated API changes
@VenomVendor VenomVendor requested a review from a team as a code owner July 10, 2024 03:14
executeRequestForPath(client, "/", "Response from /")
val transaction = chuckerInterceptorWithoutSkipping.expectTransaction()
assertThat(transaction.responseBody).isEqualTo("Response from /")
chuckerInterceptorWithoutSkipping.expectNoTransactions()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added chuckerInterceptorWithoutSkipping.expectNoTransactions() to ensure false positive checks.

Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me @VenomVendor 👍
Thanks for adding this. I've left some comments on the API but we can merge it just after it

* ".*path/ends/with/dev$".toRegex(),
* ```
*/
public fun skipPaths(vararg skipPaths: Regex): Builder =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be a vararg, it can just be a single Regex

* ".*.dev$".toRegex(),
* ```
*/
public fun skipDomain(vararg skipDomain: Regex): Builder =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add this, we'll have to add also skipDomain(vararg skipDomain: String)

Also here please remove the vararg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vararg to be removed.
Should we have both string and regex or deprecate string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have both 👍 they're so simple no need to deprecate the Regex

Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(see API comments)

Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add also skipDomain(vararg skipDomain: String) 👍 and then we can merge this

@cortinico cortinico enabled auto-merge (squash) July 16, 2024 10:09
@cortinico cortinico merged commit 5261314 into ChuckerTeam:main Jul 16, 2024
7 checks passed
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.

Ignore domains and paths from interceptor
2 participants