You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
320 B

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
}
};