Awesome
parse-github-short-url
Parse a github/npm shorthand (user/repo#branch or user/repo@version) URL into an object.
Install
npm i parse-github-short-url --save
Usage
For more use-cases see the tests
var gh = require('parse-github-short-url')
gh('tunnckoCore/parse-function')
Results in:
{
"owner": "tunnckoCore",
"name": "parse-function",
"repo": "tunnckoCore/parse-function",
"branch": null,
}
More examples
Or see the tests
// assemble/verb#1.2.3
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "1.2.3",
}
// assemble/verb@~3.0.5
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": null,
"version": "~3.0.5"
}
// assemble/verb#dev
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": "dev",
}
// assemble/verb
{
"owner": "assemble",
"name": "verb",
"repo": "assemble/verb",
"branch": null,
}
// assemble
{
"owner": "assemble",
"name": null,
"repo": null,
"branch": null,
}
// gulpjs/gulp@v3.8.1
{
"owner": "gulpjs",
"name": "gulp",
"repo": "gulpjs/gulp",
"branch": null,
"version": "v3.8.1"
}
Related
- gitclone-cli: Git clone github repository with pattern like
user/repo#branch
- github-short-url-regex: Regular expression (Regex) for matching github shorthand (user/repo#branch).
- parse-github-url: Parse a github URL into an object.
- stringify-github-short-url: Stringify github shorthand url object returned from
parse-github-short-url
- stringify-github-url: Generate a GitHub URL from an object.
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.