File: index.js

package info (click to toggle)
node-github-url-from-git 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 80 kB
  • ctags: 2
  • sloc: makefile: 7
file content (12 lines) | stat: -rw-r--r-- 320 bytes parent folder | download
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
  }
};