Skip to content

Incorrect URL parsing when path in repo contains "blob" #167

@csuich2

Description

@csuich2

It seems that parsing a URL which contains the word "blob" in the repo path section of the URL results in an incorrect parse.

Example: Adding this test to test/index.js results in a failure:

test.should("handle 'blob' in repo path", () => {
    var res = gitUrlParse("https://github.com/owner/id/tree/main/pkg/blob/data.yaml");
    test.expect(res.source).toBe("github.com");
    test.expect(res.owner).toBe("owner");
    test.expect(res.name).toBe("id");
    test.expect(res.toString()).toBe("https://gist.github.com/owner/id");
});
Error: Expected 'owner/id/tree/main' to be 'owner'

Note: I ended up here from backstage/backstage#25246

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions