Skip to content

Commit 96cd354

Browse files
added test for matching the url. Fixes #68
1 parent b2611c3 commit 96cd354

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

lib/github.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function cmdGet (msg, done) {
3030
var cache = opts.cache
3131
var registry = opts.registry + msg.name
3232

33+
console.log('Processing module: ', msg.name)
3334
cache.load$(msg.name, (err, github) => {
3435
if (err) return done(err)
3536

@@ -51,19 +52,25 @@ function cmdGet (msg, done) {
5152
var url = repository.url || ''
5253

5354
if(url.length > 0) {
55+
console.log('Matching URL: ', url)
5456
var matches = /[\/:]([^\/:]+?)[\/:]([^\/]+?)(\.git)*$/.exec(url)
55-
var params = {
56-
name: msg.name,
57-
url: url,
58-
user: matches[1] || null,
59-
repo: matches[2] || null
60-
}
6157

62-
if (!params.user || !params.repo) {
63-
return done(new Error('not found on github'))
58+
if (matches && matches.length ===2) {
59+
var params = {
60+
name: msg.name,
61+
url: url,
62+
user: matches[1] || null,
63+
repo: matches[2] || null
64+
}
65+
66+
if (!params.user || !params.repo) {
67+
return done(new Error('not found on github'))
68+
}
69+
70+
queryGithub(params, done)
71+
}else{
72+
return done(new Error('invalid github url:', url, ' for module:', msg.name))
6473
}
65-
66-
queryGithub(params, done)
6774
}
6875
else{
6976
return done(new Error('not found on github'))

0 commit comments

Comments
 (0)