ProxymanApp / Proxyman

Modern. Native. Delightful Web Debugging Proxy for macOS, iOS, and Android ⚡️
https://proxyman.io
5.72k stars 189 forks source link

[Scripting] Support native URL and URLSearchParams #1801

Open NghiaTranUIT opened 1 year ago

NghiaTranUIT commented 1 year ago

Description

Some users complain that this script can't work:

async function onRequest(context, url, request) {
  console.log(url);

  const urlItem = new URL("https://example.com?foo=1&bar=2");
  const params1 = new URLSearchParams(urlItem.search);

  // Done
  return request;
}

and get the following error:

Error: ReferenceError: Can't find variable: URL
Error: ReferenceError: Can't find variable: URLSearchParams

The problem is:

Why this feature/change is important?

NghiaTranUIT commented 1 year ago

Beta: https://download.proxyman.io/beta/Proxyman_4.12.0_Support_URL_and_URLSearchParams_for_Scripting_Tool.dmg

CleanShot 2023-10-09 at 20 21 37@2x