lib/download/git.js
function normalize(repo) {
	const regex = /^((github|gitlab|bitbucket|oschina):)?((.+):)?([^/]+)\/([^#]+)(#(.+))?$/;
	const match = regex.exec(repo);
	const type = match[2] || 'github';
	let host = match[4] || null;
	const owner = match[5];
	const name = match[6];
	const checkout = match[8] || 'master';

	if (host === null) {
		if (type === 'github') {
			host = 'github.com';
		} else if (type === 'gitlab') {
			host = 'gitlab.com';
		} else if (type === 'bitbucket') {
			host = 'bitbucket.com';
		} else if (type === 'oschina') {
			host = 'git.oschina.net';
		}
	}

	return {
		type,
		host,
		owner,
		name,
		checkout
	};
}
function normalize(repo) {
	const regex = /^((github|gitlab|bitbucket|oschina):)?((.+):)?([^/]+)\/([^#]+)(#(.+))?$/;
	const match = regex.exec(repo);
	const type = match[2] || 'github';
	let host = match[4] || null;
	const owner = match[5];
	const name = match[6];
	const checkout = match[8] || 'master';

	if (host === null) {
		if (type === 'github') {
			host = 'github.com';
		} else if (type === 'gitlab') {
			host = 'gitlab.com';
		} else if (type === 'bitbucket') {
			host = 'bitbucket.com';
		} else if (type === 'oschina') {
			host = 'git.oschina.net';
		}
	}

	return {
		type,
		host,
		owner,
		name,
		checkout
	};
}
function normalize ( repo ) { const regex = / ^((github|gitlab|bitbucket|oschina):)?((.+):)?([^/]+)\/([^#]+)(#(.+))?$ / ; const match = regex . exec ( repo ) ; const type = match [ 2 ] || 'github' ; let host = match [ 4 ] || null ; const owner = match [ 5 ] ; const name = match [ 6 ] ; const checkout = match [ 8 ] || 'master' ; if ( host === null ) { if ( type === 'github' ) { host = 'github.com' ; } else if ( type === 'gitlab' ) { host = 'gitlab.com' ; } else if ( type === 'bitbucket' ) { host = 'bitbucket.com' ; } else if ( type === 'oschina' ) { host = 'git.oschina.net' ; } } return { type , host , owner , name , checkout } ; }
Normalize a repo string.

@param {String} repo
@return {Object}
Normalize a repo string .