/usr/lib/nodejs/github-url-from-git/index.js is in node-github-url-from-git 1.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | // convert git:// form url to github URL, e.g.,
// git://github.com/bcoe/foo.git
// https://github.com/bcoe/foo.
function githubUrlFromGit(url, opts){
try {
var m = re(opts).exec(url.replace(/\.git(#.*)?$/, ''));
var host = m[1];
var path = m[2];
return 'https://' + host + '/' + path;
} catch (err) {
// ignore
}
};
// generate the git:// parsing regex
// with options, e.g., the ability
// to specify multiple GHE domains.
function re(opts) {
opts = opts || {};
// whitelist of URLs that should be treated as GitHub repos.
var baseUrls = ['gist.github.com', 'github.com'].concat(opts.extraBaseUrls || []);
// build regex from whitelist.
return new RegExp(
/^(?:https?:\/\/|git:\/\/|git\+ssh:\/\/|git\+https:\/\/)?(?:[^@]+@)?/.source +
'(' + baseUrls.join('|') + ')' +
/[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/.source
);
}
githubUrlFromGit.re = re();
module.exports = githubUrlFromGit;
|