Skip to content

Commit 2961ed9

Browse files
committed
Merge pull request #3 from bahmutov/master
merged latest code from bahmutov/parse-github-repo-url
2 parents 49dcbf8 + d81ad72 commit 2961ed9

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Parse GitHub Repo URL
1+
# parse-github-repo-url
2+
3+
> Parse a GitHub URL for user/project@version
4+
5+
# Features
26

37
Parse all the stupid ways you could write a GitHub URL in your damn `package.json`.
48
Supports:
@@ -7,22 +11,18 @@ Supports:
711
- `git://` and `.git` w/ `#commit` or `@version`
812
- `git@` and `https:git@`
913
- `www.github.com`
14+
- `gitlab.<my company name>.com/user/repo.git` parsing
1015
- All 5 different ways you could download a freaking tarball/zipball
1116

12-
[![Build status][ci-image] ][ci-url]
13-
1417
## API
1518

1619
### [user, repo, version] = parse(url)
1720

1821
`version` could be `false`y, a semantic version, a commit, or a branch, etc.
1922

2023
```js
21-
var parse = require('parse-github-repo-url')
24+
var parse = require('@bahmutov/parse-github-repo-url')
2225
parse('component/emitter#1') // => ['component', 'emitter', '1']
2326
```
2427

2528
See the tests for all the different types of supported URLs.
26-
27-
[ci-image]: https://travis-ci.org/repo-utils/parse-github-repo-url.png?branch=master
28-
[ci-url]: https://travis-ci.org/repo-utils/parse-github-repo-url

index.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
var parse = require('url').parse
32

43
module.exports = function (string) {
@@ -17,15 +16,6 @@ module.exports = function (string) {
1716
}
1817
var url = parse(string)
1918

20-
switch (url.hostname) {
21-
case 'github.com':
22-
case 'api.github.com':
23-
case 'codeload.github.com':
24-
break
25-
default:
26-
return false
27-
}
28-
2919
var path = url.pathname.replace(/\.git$/, '')
3020

3121
// https://www.npmjs.org/doc/json.html#Git-URLs-as-Dependencies

test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ describe('url parse', function () {
6666
})
6767
})
6868

69+
describe('gitlab urls', function () {
70+
it('parses https gitlab url', function () {
71+
var url = 'https://gitlab.mycompany.com/user/test1.git'
72+
var parsed = parse(url)
73+
assert.deepEqual(['user', 'test1', ''], parsed)
74+
})
75+
})
76+
6977
describe('git @ syntax', function () {
7078
it('works for git url', function () {
7179
var url = '[email protected]:bahmutov/lazy-ass.git'
@@ -79,3 +87,11 @@ describe('git @ syntax', function () {
7987
assert.deepEqual(['bahmutov', 'lazy-ass', ''], parsed)
8088
});
8189
})
90+
91+
describe('github enterprise urls', function () {
92+
it('parses https github enterprise url', function () {
93+
var url = 'https://git.mycompany.com/user/test1.git'
94+
var parsed = parse(url)
95+
assert.deepEqual(['user', 'test1', ''], parsed)
96+
})
97+
})

0 commit comments

Comments
 (0)