What would be the recommended way of deriving the following:
https://user:pass@hostname:port
From:
https://user:pass@hostname:port/p/a/t/h?q=whatevere#hash
when dealing with node.js url
module using current WHATWG URL ?
What would be the recommended way of deriving the following:
https://user:pass@hostname:port
From:
https://user:pass@hostname:port/p/a/t/h?q=whatevere#hash
when dealing with node.js url
module using current WHATWG URL ?
As of Node 8.x with the WHATWG URL API:
Pretty sure you can use standard javascript with node.js
That should give you s as the value you want.
Caz
Update -
You could also do this if you can't predict the number of / in the URL
What that does is creates an array from that string using / as the deliminator. So url[0] would be https: url[1] would be blank as its between the two / and url[2] will be user:pass@hostname:port
So if you don't need the http part you can do that and even do something like this is the https is important