1 // convert git:// form url to github URL, e.g.,
2 // git://github.com/bcoe/foo.git
3 // https://github.com/bcoe/foo.
4 function githubUrlFromGit(url, opts){
6 var m = re(opts).exec(url.replace(/\.git(#.*)?$/, ''));
9 return 'https://' + host + '/' + path;
15 // generate the git:// parsing regex
16 // with options, e.g., the ability
17 // to specify multiple GHE domains.
20 // whitelist of URLs that should be treated as GitHub repos.
21 var baseUrls = ['gist.github.com', 'github.com'].concat(opts.extraBaseUrls || []);
22 // build regex from whitelist.
24 /^(?:https?:\/\/|git:\/\/|git\+ssh:\/\/|git\+https:\/\/)?(?:[^@]+@)?/.source +
25 '(' + baseUrls.join('|') + ')' +
26 /[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/.source
30 githubUrlFromGit.re = re();
32 module.exports = githubUrlFromGit;