Skip to content

url.format ignores the "slashes" prop #48

Open

Description

@wvanvugt-speedline

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

Activity

  1. ljharb commented on Jan 27, 2021

    @ljharb
    Collaborator

    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.

  2. ljharb commented on Jan 28, 2021

    @ljharb
    Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions