Skip to content

Commit

Permalink
Fix shorthand urls
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Aug 30, 2022
1 parent 4e3b1cc commit 26cc5fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ function gitUrlParse(url) {
throw new Error("The url must be a string.");
}

const shorthandRe = /^([a-z\d-]{1,39})\/([-\.\w]{1,100})$/i

if (shorthandRe.test(url)) {
url = `https://github.com/${url}`
}

let urlInfo = gitUp(url)
, sourceParts = urlInfo.resource.split(".")
, splits = null
Expand Down
3 changes: 1 addition & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,8 @@ tester.describe("parse urls", test => {
var res = gitUrlParse(URLS.shorthand);
test.expect(res.owner).toBe("42IonicaBizau");
test.expect(res.name).toBe("git-url-parse");
test.expect(res.href).toBe(URLS.shorthand);
test.expect(res.href).toBe(res.toString());
test.expect(res.full_name).toBe("42IonicaBizau/git-url-parse");
test.expect(res.href).toBe("42IonicaBizau/git-url-parse");
});

test.should("parse subdomains", () => {
Expand Down

0 comments on commit 26cc5fe

Please sign in to comment.