Skip to content

path.normalize cannot handle paths with more than two ".." #688

@linluxiang

Description

@linluxiang

protobuf.js version: latest

The function path.normalize will remove all "../..". When it meets a path like "../../folder", it will return "folder". This behavior is totally incorrect.

Here is the the source code where it removes the double "..". https://github.com/dcodeIO/protobuf.js/blob/master/lib/path/index.js#L35

        if (parts[i] === "..") {
            if (i > 0)
                parts.splice(--i, 2);
            else if (absolute)
                parts.splice(i, 1);
            else
                ++i
<please provide a code snippet for reproduction>
pbjs ../../folder.proto
<please paste the stack trace of the error if applicable>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions