parse-github-url
Parse a github URL into an object.
HEADS UP! Breaking changes in 0.3.0!!!
See the release history for details.
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.
TOC
(TOC generated by verb using markdown-toc)
Usage
var gh = require('parse-github-url');
gh('https://github.com/jonschlinkert/micromatch');
Results in:
{
"owner": "jonschlinkert",
"name": "micromatch",
"repo": "jonschlinkert/micromatch",
"branch": "master"
}
Example results
Generated results from test fixtures:
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "1.2.3"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "branch"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "1.2.3"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "v1.2.3"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": null,
"repo": null,
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master/foo/bar"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "1.2.3"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "1.2.3"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "feature/1.2.3"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "master"
}
Related projects
is-git-url: Regex to validate that a URL is a git url. | homepage
History
v0.3.0
To be more consistent with node.js/package.json conventions, the following properties were renamed in v0.3.0
:
repo
is now name
(project name)repopath
is now repository
(project repository)user
is now owner
(project owner or org)
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 © 2016 Jon Schlinkert
Released under the MIT license.
This file was generated by verb on January 17, 2016.