Rewrite URLs in FiddlerScript

1 Answer 904 Views
Fiddler Classic Windows
Alex
Top achievements
Rank 1
Iron
Iron
Alex asked on 29 Jun 2023, 06:11 PM
Is there any instruction in FiddlerScript that can rewrite URLs?

For example, when Firefox requests Fiddler to fetch 'https://www.website.com/?sid=100', Fiddler removes the 'sid=100' variable from the URL and calls 'https://www.website.com/'. Then it returns the data to Firefox as if it were retrieved from 'https://www.website.com/?sid=100'.

Thank you!

Alex

1 Answer, 1 is accepted

Sort by
0
Accepted
Nick Iliev
Telerik team
answered on 30 Jun 2023, 12:31 PM

Hello Alex,

 

You can use Fiddler AutoResponder or FiddlerScript to redirect specific requests and create entirely custom responses or both simultaneously. Refer to the following articles for examples of how to use FiddlerScript: 

https://docs.telerik.com/fiddler/knowledge-base/fiddlerscript/modifyrequestorresponse

https://www.telerik.com/blogs/understanding-fiddlerscript 

https://www.fiddlerbook.com/fiddler/dev/scriptsamples.asp 

https://engineering.payoneer.com/fiddler-script-whats-it-good-for-a-lot-of-things-e4e9ccdfd052 

 

 

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.

Alex
Top achievements
Rank 1
Iron
Iron
commented on 30 Jun 2023, 08:02 PM

Thank you for your suggestions! Based on my initial example (if anyone needs something like this), I came up with this code:
if ((oSession.fullUrl.match(/website.com\/\?sid=...$/)) && (oSession.isHTTPS)) {
  oSession.fullUrl = oSession.fullUrl.replace(/\?sid=...$/, "");
}

Add it to CustomRules.js ('OnBeforeRequest' section), and it will work great!

Alex

Tags
Fiddler Classic Windows
Asked by
Alex
Top achievements
Rank 1
Iron
Iron
Answers by
Nick Iliev
Telerik team
Share this question
or