github-url-to-object

Extract username and repo name from various flavors of GitHub URLs

npm install github-url-to-object
23 downloads in the last week
32 downloads in the last month

github-url-to-object

Extract username and repo name from various flavors of GitHub URLs.

Installation

npm install github-url-to-object --save

Usage

Pass whatever flavor of github URL you like:

var gh = require('github-url-to-object')

gh('user/repo')
gh('https://github.com/monkey/business')
gh('https://github.com/monkey/business.git')
gh('http://github.com/monkey/business')
gh('git://github.com/monkey/business.git')

Here's what you'll get back:

{
  user: 'monkey',
  repo: 'business'
}

If you provide a non-github URL or a falsy value, you'll get null back.

Test

npm test

License

WTFPL

npm loves you