I'm trying to parse a URL and get its components like protocol,hostname,port and I guess the URL class is made for this.
But there's one thing I do not understand:
Parsing a URL like 'ftps://example.com:22' is not working.
Here's a simple test
url = new URL("ftps://example.com:22");
console.log(url);
and that's what I get in the console
[object URL] {
hash: "",
host: "",
hostname: "",
href: "ftps://example.com:22",
origin: "null",
password: "",
pathname: "//example.com:22",
port: "",
protocol: "ftps:",
...
As can be seen the 'hostname' and even the 'port' are empty.
If I do the same test with http://example.com:22
every thing is ok, 'hostname' and 'port' have the correct values.
Here's a fiddle I tested it with
What am I doing wrong? Is the URL class not the right thing to use?
Many thanks in advance for any enlightenment