Skip to content

path.resolve: clarify the example #25542

@YakovL

Description

@YakovL

https://nodejs.org/api/path.html#path_path_resolve_paths states:

The given sequence of paths is processed from right to left, with each subsequent path prepended until an absolute path is constructed. For instance, given the sequence of path segments: /foo, /bar, baz, calling path.resolve('/foo', '/bar', 'baz') would return /bar/baz.

This is something a bit diffucult to grab when in hurry (first though is: why that wouldn't be /foo/bar/baz?). One thing is "prepend" is meant not literally (otherwise that would be /barbaz). The other is the whole idea is not very usual. My suggestion is to expand this into:

The given sequence of paths is processed from right to left, with each subsequent path prepended until an absolute path is constructed. For instance, given the sequence of path segments: /foo, /bar, baz, calling path.resolve('/foo', '/bar', 'baz') would return /bar/baz because 'baz' is not an absolute path but '/bar' + '/' + 'baz' is.

But may be this is trivial for others, so I'd like to get some feedback before creating a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions