This post was written for Nodejitsu blog and is crossposted here. Nodejitsu loved what I was doing at npmawesome.com and is now supporting the project.

hosted-git-info (GitHub: npm/hosted-git-info, License: ISC) by Rebecca Turner of the NPM Inc is another fantastic ulitify module for parsing, breaking down and reusing GitHub, BitBucket and GitLab project URLs. It has a simple API and comes with full test coverage.

npm install hosted-git-info

Usage

var hostedGitInfo = require('hosted-git-info');
var info = hostedGitInfo.fromUrl('git@github.com:npmawesome/example-hosted-git-info.git');

console.log(JSON.stringify(info, null, 2));

Once you have results object, a few convinience methods are provided for your enjoyment.

console.log(info.file('/package.json'));
console.log(info.shortcut());
console.log(info.browse());
console.log(info.bugs());
console.log(info.docs());
console.log(info.https());
console.log(info.sshurl());
console.log(info.ssh());
console.log(info.path());

What Else?

I like that Rebecca Turner released version 1.0 instead of forever iterating on 0.0.x which has been the trend in the last couple of years. I’m a strong advocate of 1.0 releases as soon as it makes sense.

Checkout the runnable example and github example repository. Have you seen other modules along these lines? Please let us know in the comments!