summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/github-url-from-git/index.js
blob: 9ccc215f00a9eb1bd87191f66119c909843a3a12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
var re = /^(?:https?:\/\/|git:\/\/)?(?:[^@]+@)?(gist.github.com|github.com)[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/

module.exports = function(url){
  try {
    var m = re.exec(url.replace(/\.git$/, ''));
    var host = m[1];
    var path = m[2];
    return 'https://' + host + '/' + path;
  } catch (err) {
    // ignore
  }
};