mitmproxy-mock icon indicating copy to clipboard operation
mitmproxy-mock copied to clipboard

Is it possible to replace request path using a regex?

Open rickythefox opened this issue 2 years ago • 1 comments

I use the below config to modify a request path. Is it possible to use a regex in the modify block to get the digits from the middle of the url and move them to the end? Can't really find an answer in the docs. I'm guessing some variant of replace?

    "~^/api/foo/\\d+/bar": {
      "modify":{
        "path": "/api/foo/bar/14"
      }
    }

rickythefox avatar Oct 05 '23 11:10 rickythefox

Hi, I think there isn't a regex modify implemented for path, only for the query parameters and content. 🤔

It would be relatively simple to implement, but TBH it would potentially further clutter the already-complicated JSON format quite a bit. Still, it seems like a valid feature – do you have an idea for the syntax how it would work in natural/consistent way? (PRs also welcome!)

arkku avatar Oct 05 '23 13:10 arkku