-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: rectify transformRequestFunction precedence rules #3372
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
base: v4
Are you sure you want to change the base?
fix: rectify transformRequestFunction precedence rules #3372
Conversation
|
|
||
| return filtered; | ||
| // Apply transformRequestFunction after filtering - it has the highest priority | ||
| if (transformRequestFunction) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another option is to pass transformRequestFunction to the createRequest function and do the job there, but then the logic is split to 2 places so I picked this way.
|
This should target v4 branch |
I have to rebase then |
|
That might be a bit too much work, maybe better to recreate the PR (reset your changes, stash, hard reset to v4 upstream, unstash, resolve conflics once...) |
|
It's worth trying to cherrypick those two commits 🤷 |
refactor refactor refactor
0af2256 to
eb52536
Compare
It was not so bad |
The
transformRequestFunctioninenqueueLinkswas being applied before pattern-based filtering (globs,regexps,pseudoUrls), which meant that request options set by patterns would overwrite changes made bytransformRequestFunction. This was counterintuitive - users expectedtransformRequestFunctionto have the final say over request modifications.Solution
Reorder the processing pipeline so that
transformRequestFunctionis applied after all filtering and pattern matching:Previous order:
transformRequestFunction→ Pattern filtering → Request creationNew order: Pattern filtering → Request creation →
transformRequestFunctionChanges
packages/core/src/enqueue_links/enqueue_links.tstransformRequestFunctionexecution to aftercreateFilteredRequests()transformRequestFunctionnow operates onRequestinstances instead ofRequestOptionstransformRequestFunctionreturns a plain object (converts it to aRequestinstance)labeloptionglobs,regexps,pseudoUrls)transformRequestFunctiontest/core/enqueue_links/enqueue_links.test.tstransformRequestFunctionoverriding pattern labelstransformRequestFunctionmodifying other request propertiestransformRequestFunctioncloses #3070