Open jsorge opened 3 years ago
Hi @jsorge Unfortunately, the scripting could not use NodeJS modules because the scripting is built on top of JavascriptCore, which is a pure JS framework.
JavascriptCore doesn't support this URL too
Just wondering: How often do you use URL for the scripting? If it's an important class, I might find a solution to support it 👍
Ah yeah that makes sense @NghiaTranUIT, thanks for the explanation!
It's not something I'm doing a bunch (today was the first time) but I do have to find an alternate solution. I really only need the value of a path parameter so maybe it's time to turn to a regex.
You can easily get a path of the URL by using
const path = request.path;
Ref: https://docs.proxyman.io/scripting/script#onrequest-object-format
Ah yeah this is a bit different. We route to new places in our app through protocol URIs that come in the payload as strings. I need to parse one of those 😊
Thanks. I will find a way to support native URL if it's possible 👍
https://github.com/zloirock/core-js has well-designed implementations of URL
and URLSearchParams
(among many others) which are designed to work in buggy or unusual environments that don't support them natively. You could probably inject them as globals into JavaScriptCore and have them work as if they were a native implementation.
Thanks for your suggestion @Zirro Let me play around and try to integrate it 👍
Proxyman version? (Ex. Proxyman 1.4.3)
2.25.0
macOS Version? (Ex. mac 10.14)
11.3.1
In Scripting, is it possible to use the
url
module (I'm not sure what it's called in JS) to parse a URL? I've got this code in a CodeRunner window using Node and it works:However when I try to do this in the Scripting window I get this error:
I'm hoping there's a way to do what I'm after. Thanks for a great app; Proxyman is fantastic!