[GH-ISSUE #938] Map remote: Can't map two URLs with partial path matching #934

Open
opened 2026-03-03 19:23:07 +03:00 by kerem · 9 comments
Owner

Originally created by @cameroncooke on GitHub (Jul 15, 2021).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/938

Originally assigned to: @NghiaTranUIT on GitHub.

I want to map the following URL to the target URL while preserving some of the path:

api.example.com/v1/* -> `example.com/service/api/*

I want to use the path from the * onwards as the entire path to be used as the input on the target path.

Example matches would be:

https://api.example.com/v1/test/thing -> https://example.com/service/api/test/thing
https://api.example.com/v1/something/else -> https://example.com/service/api/something/else

I can't see a way to do this currently because the Map Remote tool allows you to replace the entire path but not match part of the path.

I thought about using the RegEx feature and using capture groups but I don't think you can use the replacements patterns in the "Map To -> Path" field.

Proxyman version? (Ex. Proxyman 1.4.3)

2.29.0 (22900)

macOS Version? (Ex. mac 10.14)

12.0 Beta (21A5284e)

Steps to reproduce

Expected behavior

To be able to use the wildcard part of the source path as the target path or support regex capture groups from the source URL in the target path field.

Screenshots (optional)

Screenshot 2021-07-15 at 11 42 28
Originally created by @cameroncooke on GitHub (Jul 15, 2021). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/938 Originally assigned to: @NghiaTranUIT on GitHub. I want to map the following URL to the target URL while preserving **some** of the path: ``` api.example.com/v1/* -> `example.com/service/api/* ``` I want to use the path from the `*` onwards as the entire path to be used as the input on the target path. Example matches would be: ``` https://api.example.com/v1/test/thing -> https://example.com/service/api/test/thing https://api.example.com/v1/something/else -> https://example.com/service/api/something/else ``` I can't see a way to do this currently because the Map Remote tool allows you to replace the entire path but not match part of the path. I thought about using the RegEx feature and using capture groups but I don't think you can use the replacements patterns in the "Map To -> Path" field. ### Proxyman version? (Ex. Proxyman 1.4.3) 2.29.0 (22900) ### macOS Version? (Ex. mac 10.14) 12.0 Beta (21A5284e) ### Steps to reproduce ### Expected behavior To be able to use the wildcard part of the source path as the target path or support regex capture groups from the source URL in the target path field. ### Screenshots (optional) <img width="988" alt="Screenshot 2021-07-15 at 11 42 28" src="https://user-images.githubusercontent.com/630601/125775561-8eb27310-1efa-432d-82f4-3250b2b56819.png">
Author
Owner

@chaoyangnz commented on GitHub (Nov 4, 2021):

yep, it is useless when we cannot capture the group and do replacement

<!-- gh-comment-id:961427598 --> @chaoyangnz commented on GitHub (Nov 4, 2021): yep, it is useless when we cannot capture the group and do replacement
Author
Owner

@NghiaTranUIT commented on GitHub (Nov 5, 2021):

It's straightforward to achieve it if you're using the Scripting tool @chaoyangnz

Please check out this snippet code: https://docs.proxyman.io/scripting/snippet-code#change-request-destination-scheme-host-port-path

Just use some if statement and write your own logic with simple Javascript code 👍

If you'd like using Regex, it's possible too: https://docs.proxyman.io/scripting/snippet-code#regex

I'm reluctant to implement this feature because it might introduce many edge cases that I could not cover yet.

<!-- gh-comment-id:961680195 --> @NghiaTranUIT commented on GitHub (Nov 5, 2021): It's straightforward to achieve it if you're using the Scripting tool @chaoyangnz Please check out this snippet code: https://docs.proxyman.io/scripting/snippet-code#change-request-destination-scheme-host-port-path Just use some if statement and write your own logic with simple Javascript code 👍 If you'd like using Regex, it's possible too: https://docs.proxyman.io/scripting/snippet-code#regex I'm reluctant to implement this feature because it might introduce many edge cases that I could not cover yet.
Author
Owner

@cameroncooke commented on GitHub (Nov 5, 2021):

To be fair, it’s not that simple. Requires learning JavaScript and
understanding the API.

Being able to just pattern match is far easier. I’m not a fan of in-app
scripting environments. Seems like a way to say to your end-users who need
a feature “write your own”. The thing is we pay for this product already.
If I need to mock APIs I’ll use Postman or any other dedicated tool.

If adding this as a new feature could introduce edge cases god knows what
scripting this could do?

How comes Charles has no problem doing this?

If this app has a robust test suite as I would expect then adding this
feature should be fairly easy to validate.

On Fri, 5 Nov 2021 at 07:30, Nghia Tran @.***> wrote:

It's straightforward to achieve it if you're using the Scripting tool
@chaoyangnz https://github.com/chaoyangnz

Please check out this snippet code:
https://docs.proxyman.io/scripting/snippet-code#change-request-destination-scheme-host-port-path

Just use some if statement and write your own logic with simple Javascript
code 👍

If you'd like using Regex, it's possible too:
https://docs.proxyman.io/scripting/snippet-code#regex

I'm reluctant to implement this feature because it might introduce many
edge cases that I could not cover yet.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/ProxymanApp/Proxyman/issues/938#issuecomment-961680195,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAEZ6SOM2NEPZY7PLS55JSTUKOBX3ANCNFSM5ANJDNZA
.

<!-- gh-comment-id:961698336 --> @cameroncooke commented on GitHub (Nov 5, 2021): To be fair, it’s not that simple. Requires learning JavaScript and understanding the API. Being able to just pattern match is far easier. I’m not a fan of in-app scripting environments. Seems like a way to say to your end-users who need a feature “write your own”. The thing is we pay for this product already. If I need to mock APIs I’ll use Postman or any other dedicated tool. If adding this as a new feature could introduce edge cases god knows what scripting this could do? How comes Charles has no problem doing this? If this app has a robust test suite as I would expect then adding this feature should be fairly easy to validate. On Fri, 5 Nov 2021 at 07:30, Nghia Tran ***@***.***> wrote: > It's straightforward to achieve it if you're using the Scripting tool > @chaoyangnz <https://github.com/chaoyangnz> > > Please check out this snippet code: > https://docs.proxyman.io/scripting/snippet-code#change-request-destination-scheme-host-port-path > > Just use some if statement and write your own logic with simple Javascript > code 👍 > > If you'd like using Regex, it's possible too: > https://docs.proxyman.io/scripting/snippet-code#regex > > I'm reluctant to implement this feature because it might introduce many > edge cases that I could not cover yet. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/ProxymanApp/Proxyman/issues/938#issuecomment-961680195>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAEZ6SOM2NEPZY7PLS55JSTUKOBX3ANCNFSM5ANJDNZA> > . >
Author
Owner

@NghiaTranUIT commented on GitHub (Nov 5, 2021):

it makes sense that Proxyman should implement this feature, which is supported by Charles Proxy. I will put it in our road map 👍

<!-- gh-comment-id:961699848 --> @NghiaTranUIT commented on GitHub (Nov 5, 2021): it makes sense that Proxyman should implement this feature, which is supported by Charles Proxy. I will put it in our road map 👍
Author
Owner

@cameroncooke commented on GitHub (Nov 5, 2021):

Thank you for being open to being challenged, it's quite refreshing. Keep up the good work!

<!-- gh-comment-id:961700483 --> @cameroncooke commented on GitHub (Nov 5, 2021): Thank you for being open to being challenged, it's quite refreshing. Keep up the good work!
Author
Owner

@chaoyangnz commented on GitHub (Nov 5, 2021):

It's straightforward to achieve it if you're using the Scripting tool @chaoyangnz

Please check out this snippet code: https://docs.proxyman.io/scripting/snippet-code#change-request-destination-scheme-host-port-path

Just use some if statement and write your own logic with simple Javascript code 👍

If you'd like using Regex, it's possible too: https://docs.proxyman.io/scripting/snippet-code#regex

I'm reluctant to implement this feature because it might introduce many edge cases that I could not cover yet.

Definitely I know scripting can achieve.
It’s nice to enhance scripting tool, I am not sure which JS engine is used, I cannot use lots of JS objects which is normally in browser and nodejs. When I need to implement a relatively real-life script, some libs are missing and even it provides the capability of adding libs or add-ons. It is actually not easy.

a simple requirement I’d like to forward a request to a server, I cannot modify request url directly, I have to parse URL into parts and assign to request host/port/path/queries, and URL parsing this basic function is not pre-defined.

Please consider this feature.

<!-- gh-comment-id:961758544 --> @chaoyangnz commented on GitHub (Nov 5, 2021): > It's straightforward to achieve it if you're using the Scripting tool @chaoyangnz > > Please check out this snippet code: https://docs.proxyman.io/scripting/snippet-code#change-request-destination-scheme-host-port-path > > Just use some if statement and write your own logic with simple Javascript code 👍 > > If you'd like using Regex, it's possible too: https://docs.proxyman.io/scripting/snippet-code#regex > > I'm reluctant to implement this feature because it might introduce many edge cases that I could not cover yet. Definitely I know scripting can achieve. It’s nice to enhance scripting tool, I am not sure which JS engine is used, I cannot use lots of JS objects which is normally in browser and nodejs. When I need to implement a relatively real-life script, some libs are missing and even it provides the capability of adding libs or add-ons. It is actually not easy. a simple requirement I’d like to forward a request to a server, I cannot modify request url directly, I have to parse URL into parts and assign to request host/port/path/queries, and URL parsing this basic function is not pre-defined. Please consider this feature.
Author
Owner

@chaoyangnz commented on GitHub (Nov 5, 2021):

To be fair, it’s not that simple. Requires learning JavaScript and understanding the API. Being able to just pattern match is far easier. I’m not a fan of in-app scripting environments. Seems like a way to say to your end-users who need a feature “write your own”. The thing is we pay for this product already. If I need to mock APIs I’ll use Postman or any other dedicated tool. If adding this as a new feature could introduce edge cases god knows what scripting this could do? How comes Charles has no problem doing this? If this app has a robust test suite as I would expect then adding this feature should be fairly easy to validate.

I agree with you. Most of the time, we just need to map a url so as to point to another.

Scripting is flexible, but at the end of the day, it will end up with the script management: debugging, version control, sharing with peers etc.

<!-- gh-comment-id:961763891 --> @chaoyangnz commented on GitHub (Nov 5, 2021): > To be fair, it’s not that simple. Requires learning JavaScript and understanding the API. Being able to just pattern match is far easier. I’m not a fan of in-app scripting environments. Seems like a way to say to your end-users who need a feature “write your own”. The thing is we pay for this product already. If I need to mock APIs I’ll use Postman or any other dedicated tool. If adding this as a new feature could introduce edge cases god knows what scripting this could do? How comes Charles has no problem doing this? If this app has a robust test suite as I would expect then adding this feature should be fairly easy to validate. > […](#) I agree with you. Most of the time, we just need to map a url so as to point to another. Scripting is flexible, but at the end of the day, it will end up with the script management: debugging, version control, sharing with peers etc.
Author
Owner

@NghiaTranUIT commented on GitHub (Nov 16, 2021):

Hey @cameroncooke and @chaoyangnz, I've fixed this problem on this beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.35.0_Partial_group_matching_map_remote.dmg

From now, Map Remote can perform "Partial Matching". For instance,

https://httpbin.org/v1/test/thing?data=123 -> http://httpbin.org:80/server/api/test/thing?data=123

At the moment, partial matching (*) is only applied for the Path and it requires two *.

Screen_Shot_2021-11-16_at_14_30_24 Screen_Shot_2021-11-16_at_14_30_10
<!-- gh-comment-id:970243406 --> @NghiaTranUIT commented on GitHub (Nov 16, 2021): Hey @cameroncooke and @chaoyangnz, I've fixed this problem on this beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.35.0_Partial_group_matching_map_remote.dmg From now, Map Remote can perform "Partial Matching". For instance, - From: httpbin.org/v1/* - to: http://httpbin.org:80/server/api/* ``` https://httpbin.org/v1/test/thing?data=123 -> http://httpbin.org:80/server/api/test/thing?data=123 ``` At the moment, partial matching (`*`) is only applied for the Path and it requires two `*`. <img width="1513" alt="Screen_Shot_2021-11-16_at_14_30_24" src="https://user-images.githubusercontent.com/5878421/141988371-c81aee31-9399-4b34-b832-87a22279f48c.png"> <img width="1204" alt="Screen_Shot_2021-11-16_at_14_30_10" src="https://user-images.githubusercontent.com/5878421/141988360-bc5828e0-0db7-492b-a355-853e60cee7c8.png">
Author
Owner

@cameroncooke commented on GitHub (Nov 30, 2021):

Hi,

Thanks for this, looks great, I've not had time to test it yet but it looks
exactly what we needed so thank you so much!

Cameron.

On Tue, 16 Nov 2021 at 12:54, Nghia Tran @.***> wrote:

Hey @cameroncooke https://github.com/cameroncooke and @chaoyangnz
https://github.com/chaoyangnz, I've fixed this problem on this beta
build:
https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.35.0_Partial_group_matching_map_remote.dmg

From now, Map Remote can perform "Partial Matching". For instance,

https://httpbin.org/v1/test/thing?data=123 -> http://httpbin.org:80/server/api/test/thing?data=123

At the moment, partial matching (*) is only applied for the Path.

[image: Screen_Shot_2021-11-16_at_14_30_24]
https://user-images.githubusercontent.com/5878421/141988371-c81aee31-9399-4b34-b832-87a22279f48c.png

[image: Screen_Shot_2021-11-16_at_14_30_10]
https://user-images.githubusercontent.com/5878421/141988360-bc5828e0-0db7-492b-a355-853e60cee7c8.png


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/ProxymanApp/Proxyman/issues/938#issuecomment-970243406,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAEZ6SNVO4FWCYVWGJ5S2E3UMJIARANCNFSM5ANJDNZA
.

<!-- gh-comment-id:982544272 --> @cameroncooke commented on GitHub (Nov 30, 2021): Hi, Thanks for this, looks great, I've not had time to test it yet but it looks exactly what we needed so thank you so much! Cameron. On Tue, 16 Nov 2021 at 12:54, Nghia Tran ***@***.***> wrote: > Hey @cameroncooke <https://github.com/cameroncooke> and @chaoyangnz > <https://github.com/chaoyangnz>, I've fixed this problem on this beta > build: > https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.35.0_Partial_group_matching_map_remote.dmg > > From now, Map Remote can perform "Partial Matching". For instance, > > - From: httpbin.org/v1/* > - to: http://httpbin.org:80/server/api/* > > https://httpbin.org/v1/test/thing?data=123 -> http://httpbin.org:80/server/api/test/thing?data=123 > > At the moment, partial matching (*) is only applied for the Path. > > [image: Screen_Shot_2021-11-16_at_14_30_24] > <https://user-images.githubusercontent.com/5878421/141988371-c81aee31-9399-4b34-b832-87a22279f48c.png> > > [image: Screen_Shot_2021-11-16_at_14_30_10] > <https://user-images.githubusercontent.com/5878421/141988360-bc5828e0-0db7-492b-a355-853e60cee7c8.png> > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/ProxymanApp/Proxyman/issues/938#issuecomment-970243406>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAEZ6SNVO4FWCYVWGJ5S2E3UMJIARANCNFSM5ANJDNZA> > . >
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#934
No description provided.