I have a GAS project and I need to parse some URLs into their hostname and pathname properties as follows.
const url = new URL( 'http://www.example.com/cats', );
const { hostname, pathname, } = url;
Here are some docs on the above URL constructor method. [1] | [2]
The above code produces the following error.
Error message:ReferenceError: URL is not defined (line 64, file "Code")
What am I missing? How can I parse my URLs using GAS?