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

fix: make mock intercept agnostic to query key ordering #1607

Merged
merged 1 commit into from Aug 18, 2022

Conversation

James1x0
Copy link
Contributor

Proposed solution to #1600


  • Added test for mis-ordered keys, verified failure against current functionality
  • Added parsing for path comparison

Background: intercept does not match requests with query parameters if the keys are in a different order. From an http-standpoint query parameter key ordering does not matter. This causes some confusion if the intercept doesn't work for someone using the library.

Proposed solution: Sort the keys to build a "safeUrl" to prepare a comparable value using URLSearchParams.

Based on Matteo's feedback we may also want to introduce some diagnostic hooks if requests are missed. I'll follow up with another PR.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit e46d8bf into nodejs:main Aug 18, 2022
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
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.

None yet

2 participants