Skip to content

Commit e810584

Browse files
committed
Merge branch 'fix-name-organization-on-issueURL' of github.com:msivasubramaniaan/git-url-parse into new-version
2 parents 4c01a68 + 2c26c51 commit e810584

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,13 @@ function gitUrlParse(url) {
157157
const blobIndex = splits.indexOf("blob", 2);
158158
const treeIndex = splits.indexOf("tree", 2);
159159
const commitIndex = splits.indexOf("commit", 2);
160+
const issuesIndex = splits.indexOf("issues", 2);
160161
const srcIndex = splits.indexOf("src", 2);
161162
const rawIndex = splits.indexOf("raw", 2);
162163
const editIndex = splits.indexOf("edit", 2);
163164
nameIndex = dashIndex > 0 ? dashIndex - 1
164165
: blobIndex > 0 ? blobIndex - 1
166+
: issuesIndex > 0 ? issuesIndex - 1
165167
: treeIndex > 0 ? treeIndex - 1
166168
: commitIndex > 0 ? commitIndex - 1
167169
: srcIndex > 0 ? srcIndex - 1
@@ -171,7 +173,7 @@ function gitUrlParse(url) {
171173

172174
urlInfo.owner = splits.slice(0, nameIndex).join('/');
173175
urlInfo.name = splits[nameIndex];
174-
if (commitIndex) {
176+
if (commitIndex && issuesIndex < 0) {
175177
urlInfo.commit = splits[nameIndex + 2]
176178
}
177179
}

test/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const URLS = {
1313
, ref: "https://github.com/42IonicaBizau/git-url-parse/blob/master/test/index.js"
1414
, shorthand: "42IonicaBizau/git-url-parse"
1515
, commit: "https://github.com/42IonicaBizau/git-url-parse/commit/9c6443245ace92d237b7b274d4606a616e071c4e"
16+
, issue: "https://github.com/IonicaBizau/git-url-parse/issues/133"
1617
};
1718

1819
const gitUser = (url) => url.replace('custom-user@', 'git@');
@@ -514,4 +515,10 @@ tester.describe("parse urls", test => {
514515
test.expect(res.name).toBe("git-url-parse");
515516
test.expect(res.commit).toBe("9c6443245ace92d237b7b274d4606a616e071c4e");
516517
});
518+
519+
test.should("parse issues urls", () => {
520+
var res = gitUrlParse(URLS.issue);
521+
test.expect(res.name).toBe("git-url-parse");
522+
test.expect(res.organization).toBe("IonicaBizau");
523+
});
517524
});

0 commit comments

Comments
 (0)