Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ function gitUrlParse(url) {
const rawIndex = splits.indexOf("raw", 2);
const editIndex = splits.indexOf("edit", 2);
nameIndex = dashIndex > 0 ? dashIndex - 1
: blobIndex > 0 && treeIndex > 0 ? Math.min(blobIndex - 1, treeIndex - 1)
: blobIndex > 0 ? blobIndex - 1
: issuesIndex > 0 ? issuesIndex - 1
: treeIndex > 0 ? treeIndex - 1
Expand Down
11 changes: 11 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,4 +521,15 @@ tester.describe("parse urls", test => {
test.expect(res.name).toBe("git-url-parse");
test.expect(res.organization).toBe("IonicaBizau");
});

// blob in repo path: https://github.com/IonicaBizau/git-url-parse/issues/167
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.pathname).toBe("/owner/id/tree/main/pkg/blob/data.yaml");
test.expect(res.filepath).toBe("pkg/blob/data.yaml");
test.expect(res.toString()).toBe("https://github.com/owner/id");
});
});