Bug1038424

What do you think about using the [built-in URL parser](https://developer.mozilla.org/en-US/docs/Web/API/URL)?

E.g.
``` js
var parsedURL = new URL(url);
if (parsedURL.protocol == "http") { parsedURL.protocol = "https"; }
if (parsedURL.protocol == "ws") { parsedURL.protocol = "wss"; }
return parsedURL.href;
```