defunctzombie / node-url

node.js core url module as a module
MIT License
375 stars 96 forks source link

url.format ignores the "slashes" prop #48

Open wvanvugt-speedline opened 4 years ago

wvanvugt-speedline commented 4 years ago

URL.format includes the leading slashes regardless of what the slashes property is set to. The behavior is not present in node's URL package.

const nodeUrl = require("url");
const npmUrl = require("./node_modules/url");
console.log(nodeUrl.format({ hostname: "example.com", slashes: false }));
// => example.com (good)
console.log(npmUrl.format({ hostname: "example.com", slashes: false }));
// => //example.com (bad)
console.log(nodeUrl.format({ hostname: "example.com", slashes: true }));
// => //example.com
console.log(npmUrl.format({ hostname: "example.com", slashes: true }));
// => //example.com

I am using: NodeJS 10.16.0 url package 0.11.0

ljharb commented 3 years ago

Thanks, this definitely seems like a bug (altho it's also possible that these examples do the same thing in an older version of node).

Once tests on this repo are sorted out, a PR with a failing test case (with or without a fix) would be appreciated.

ljharb commented 3 years ago

See #53 as well; this will be addressed as part of "node catchup".