mirror of
https://github.com/ProxymanApp/Proxyman.git
synced 2026-04-27 00:55:57 +03:00
[GH-ISSUE #511] Mapping with Non-deterministic Ordering of Query Parameters #507
Labels
No labels
Discussion
Feature request
In Progress...
Plugins
Waiting response
Windows
Windows
bug
duplicate
enhancement
feature
good first issue
iOS
macOS 10.11
question
wontfix
✅ Done
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Proxyman#507
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @grantjbutler on GitHub (May 28, 2020).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/511
Originally assigned to: @NghiaTranUIT on GitHub.
Proxyman version? (Ex. Proxyman 1.4.3)
Version 1.23.0 (12300)
macOS Version? (Ex. mac 10.14)
macOS 10.15.4 (19E287)
Steps to reproduce
Set up mapping for a URL that has multiple query parameters in it (I've tested with local mapping, so I'm not sure if this applies to remote mapping, too). For example, a URL that looks something like
https://domain.tld/path?param1=value1¶m2=value2. With that mapping enable, sometimes requests are still let through to the remote server because the ordering of query parameters has changed. If we're using the above URL as an example, requests matching those exact query parameters will be served the local file, but requests with the URLhttps://domain.tld/path?param2=value2¶m1=value1will not. The only thing that has changed about this URL is the ordering of the parameters.To handle both URLs where the ordering changes, I have to create a new mapping for each combination of parameters. This is problematic because it is a factorial problem. For however many parameters I have, I have to create
n!mappings to handle all possible permutations of parameter ordering. This creates extra work on my end, as if I make a change to the response, I have to make the same change across multiple mappings.Expected behavior
If I have mapping set up for the URL
https://domain.tld/path?param1=value1¶m2=value2, I would like for requests matchinghttps://domain.tld/path?param1=value1¶m2=value2andhttps://domain.tld/path?param2=value2¶m1=value1to both match the mapping and be served the local content. However, I realize that this only works because the ordering of parameters does not affect the functionality. That these two URLs are functionally equivalent. However, this is not true of a URL with query parameters that, say, match to an array (for example,https://domain.tld/path?param[]=value1¶m[]=value2). Changing the order of the parameters does change the meaning of the request (maybe these values indicate some kind of sorting method, where each value corresponds to a column on a database table, and the response will be sorted by the given values in the order they are given. In such a case, changing the order of the parameters does change the functionality of the endpoint).I'm not sure how to resolve that part of it. Maybe Proxyman checks if there is an array query parameter and if it is assigned multiple values. If it detects that, then maybe it falls back to the old behavior, with some kind of message to indicate how Proxyman will behave? Maybe Proxyman needs an additional check box when creating the mapping for the user to indicate whether order matters, which, if it does not, then Proxyman would treat requests with different parameter orderings as the same requests. I could then have one mapping to handle all possible permutations of ordering of parameters.
Screenshots (optional)
@NghiaTranUIT commented on GitHub (May 29, 2020):
Thanks for the detailed proposal. It totally makes sense that Proxyman should add a checkbox to determine if the Query Order should be evaluated when finding the matching rule.
I will consider and support it soon, after the Core V2 is out. For now, I would suggest duplicating the rule with a different param combination for the workaround as you described.
@miguelrojascortes commented on GitHub (Sep 16, 2024):
Any updates on this proposal? It would be super helpful since mapping all the possible query parameter combinations is really annoying and time-consuming!
@NghiaTranUIT commented on GitHub (Sep 17, 2024):
@miguelrojascortes It's really simple to use the Scripting Tool.
Here is the code: Map with non-ordering Query, and map the Response Body with a local file, similar to the Map Local.
For example, the following will work with:
https://yourdomain.com/*, select Method = ANY, and check on the "Include all subpath"You can write your own If-else logic to match your URL 👍
Screenshots
@NghiaTranUIT commented on GitHub (Sep 17, 2024):
You can find a list of snippet code at https://docs.proxyman.io/scripting/snippet-code
It's super useful 👍