Skip to content

Path.format doesn't concat .name and .ext #6437

Description

@eight04
  • Version: v4.4.3
  • Platform: Windows 7 64-bit
  • Subsystem: path

https://nodejs.org/docs/v4.4.3/api/path.html#path_path_format_pathobject

Under path.format, the document said that:

If the base property is not supplied, a concatenation of the name property and the ext property will be used as the base property.

However, This feature seems not working properly. With following code:

var path = require("path");

var file = path.format({
    root : "C:\\",
    dir : "C:\\path\\dir",
    ext : ".txt",
    name : "file"
});

console.log(file);

I always get:

C:\path\dir\

Activity

  1. added
    pathIssues and PRs related to the path subsystem.
    on Apr 28, 2016
  2. mscdex commented on Apr 28, 2016

    @mscdex
    Contributor

    It works for me in v5.10.1 and v6.0.0. Looks like something may need to be backported?

  3. nwoltman commented on Apr 29, 2016

    @nwoltman
    Contributor

    For some reason the docs were backported but the code wasn't.

    The PR that introduced that functionality is #2408. That PR has the semver-major label so that's why it was never backported. Also, after @mscdex re-wrote the path module, a lot of commits were never backported. Those are being tracked in this issue.

    So either something needs to be backported or the doc changes need to be reverted in the v4.x branch.

  4. jasnell commented on Apr 29, 2016

    @jasnell
    Member

    Odd... the doc change may have been picked up along with some other doc updates and just overlooked. The right thing to do would be to revert the doc change in the v4.x.

  5. MylesBorins commented on Apr 29, 2016

    @MylesBorins
    Contributor
  6. nwoltman commented on Apr 29, 2016

    @nwoltman
    Contributor

    I think these are all of them: daf3ef6, 0943001 (contains other changes), 79d26ae, aed22d0

    bf1fe46 also changes the path.format docs and was made after 0943001 but it should be kept since it has nothing to do with the changed functionality.

  7. MylesBorins commented on May 2, 2016

    @MylesBorins
    Contributor

    I have submitted a change to revert the docs. Thanks for reporting @eight04

  8. imyller commented on Sep 16, 2016

    @imyller
    Member

    Closing this issue as resolved with PR #6530

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

    pathIssues and PRs related to the path subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions