parse-github-url
Parse a github URL into an object.
Why another GitHub URL parser library?
Seems like every lib I've found does too much, like both stringifying and parsing, or converts the URL from one format to another, only returns certain segments of the URL except for what I need, yields inconsistent results or has poor coverage.
Install with npm
npm i parse-github-url --save
Usage
var gh = require('parse-github-url');
gh('https://github.com/jonschlinkert/micromatch');
Results in:
{
"user": "jonschlinkert",
"repo": "micromatch",
"repopath": "jonschlinkert/micromatch",
"branch": "master"
}
Example results
Generated results from test fixtures:
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "1.2.3"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "branch"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "1.2.3"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "v1.2.3"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": null,
"repopath": null,
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master/foo/bar"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "1.2.3"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "1.2.3"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "feature/1.2.3"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
{
"user": "assemble",
"repo": "verb",
"repopath": "assemble/verb",
"branch": "master"
}
Related projects
is-git-url: Regex to validate that a URL is a git url.
Running tests
Install dev dependencies:
npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb-cli on March 25, 2015.