This repository was archived by the owner on Apr 22, 2023. It is now read-only.
Description In:
http://nodejs.org/api/url.html#url_url_format_urlobj
It states that: "The protocols http, https, ftp, gopher, file will be postfixed with :// (colon-slash-slash)".
I'm unsure whether urlObjects are meant to be modified so they can be formatted again (although this seems reasonable).
It appears that if the parsed URL was not fully qualified then assigning a protocol doesn't postfix the :// (colon-slash-slash) as expected.
Code below demonstrates the problem:
var url = require("url");
var assert = require("assert");
var fqdnUrl = "http://www.google.com/";
var fqdnObject = url.parse(fqdnUrl);
assert.equal(fqdnObject.protocol, "http:");
assert.equal(url.format(fqdnObject), fqdnUrl);
var partialUrl = "www.google.com/";
var partialObject = url.parse(partialUrl);
assert(!partialObject.protocol);
partialObject.protocol = fqdnObject.protocol; // "http:" (but "http" should also work)
assert.equal(url.format(partialObject), fqdnUrl); // <-- This assertion fails.
Reactions are currently unavailable
In:
It states that: "The protocols http, https, ftp, gopher, file will be postfixed with :// (colon-slash-slash)".
I'm unsure whether urlObjects are meant to be modified so they can be formatted again (although this seems reasonable).
It appears that if the parsed URL was not fully qualified then assigning a protocol doesn't postfix the :// (colon-slash-slash) as expected.
Code below demonstrates the problem: