Search code examples
charles-proxy

Charles Proxy Rewrite & MapLocal - how to match exact query


I only want to return certain response specifically for /path/embed=profile&prefetch=true&couples_only=false and NOT embed=profile&prefetch=true&couples_only=false&ANYTHINGELSE

But Charles seems to be treating the 2 queries the same enter image description here

What I've tried

  1. /path/embed=profile&prefetch=true&couples_only=false? - hoping the ? will match 1 character or nothing, ruling out the wanted longer queries enter image description here

  2. embed=profile&prefetch=true&couples_only=false(?!&) - standard regex, tested in regexr.com

What else can I do?


Solution

  • From what I remember, it's a bug and it hasn't fixed ever since.

    You might try Proxyman, which is similar to Charles and it will solve your problem.

    Here is the step:

    1. Setup the certificate on your macOS (Certificate -> Install on macOS)
    2. Make a request
    3. Right-click to show a menu context -> Tool -> Map Local or Breakpoint

    enter image description here

    1. Create a rule with default value -> It will match exactly the query as you wish.
    • For the Map Local, you can modify the local file in the Editor.
    • For the Scripting (It's the same with ReWrite, but write by Javascript)

    Map Local

    • Disclaimer: I create this app. Hope that it can help you for daily works.