Regular expression in Fiddler Everywhere

2 Answers 345 Views
Fiddler Everywhere MacOS
Tihamer
Top achievements
Rank 1
Iron
Tihamer asked on 16 Jun 2023, 01:31 PM

In Fiddler Everywhere on Mac I try creating a redirect to catch requests sent to https://my.url.here/this/that/0.0.112/filename and serve some locally stored files instead. This is for a development environment on a project. I have created the following rule:

Conditions:
URL Contains: https://my.url.here/this/that/

Rules:
Update Url
Regular expression:
/https:\/\/my.url.here\/this\/that\/[0-9\.]+\/(.+)
/Users/firtname.lastname/Projects/projectname/dist/$1

The Condition is triggered because I also have a rule to color the requests and I can see that the requests are colored as I expect it. The regex Rule is probably not executed because the files are still served from https://my.url.here/this/that/... instead of the locally stored files.

Could you please advise what I am doing wrong with my regex or anything else?

Thank you.

Tihamer
Top achievements
Rank 1
Iron
commented on 16 Jun 2023, 04:54 PM

I have figured out that the regex:

https://my.url.here/this/that/[0-9\.]/(.+)

works fine and triggers the rule, because if I use the replacement string: https://google.com/search?q=$1 is executed correctly until google refuses to connect. But if I set the local file for Fiddler to return, it doesn't work: /Users/firtname.lastname/Projects/projectname/dist/$1.

Can anyone advise how to return local files by regex search/replace?

2 Answers, 1 is accepted

Sort by
0
Accepted
Nick Iliev
Telerik team
answered on 19 Jun 2023, 06:51 AM

Hello Tihamer,

 

The Update URL action will only change the string value for the destination URL - it can not be used to replace the actual HTTP Request and Response. So when you use regular expression alongside Update URL, you can only use it to change the destination endpoint address.

You can use the URL match condition with a regular expression (to match complex conditions based on your requirements) and serve the custom HTTP Response through one of the file options (like Manual Response, Response File, etc.).

I hope the above will be helpful. Let us know if you have more questions about Fiddler.

 

Regards,
Nick Iliev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Tihamer
Top achievements
Rank 1
Iron
answered on 19 Jun 2023, 06:59 AM

Thank you for the answer Nick.

Using your approach to have URL match regular expression and serve a static file with Response File, doesn't work for me because my filenames change dynamically. As a future development, you could create regex search/replace for the Response File option too.

I found a different solution: start a local http server to serve the locally stored files and use URL match regular expression and Update URL rule to redirect to the local http server. It works fine now, thank you.

Tags
Fiddler Everywhere MacOS
Asked by
Tihamer
Top achievements
Rank 1
Iron
Answers by
Nick Iliev
Telerik team
Tihamer
Top achievements
Rank 1
Iron
Share this question
or