3.0.0 • Published 11 years ago
giturlparse v3.0.0

git-url-parse 
Parses and stringifies git urls.
Installation
$ npm i git-url-parseExample
// Dependencies
var GitUrlParse = require("git-url-parse");
console.log(GitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git"));
// => { protocol: 'ssh'
// , source: 'github.com'
// , owner: 'IonicaBizau'
// , name: 'node-git-url-parse'
// , _: 'git@github.com:IonicaBizau/node-git-url-parse.git'
// , toString: [Function] }
console.log(GitUrlParse("https://github.com/IonicaBizau/node-git-url-parse.git"));
// => { protocol: 'https'
// , source: 'github.com'
// , owner: 'IonicaBizau'
// , name: 'node-git-url-parse'
// , _: 'https://github.com/IonicaBizau/node-git-url-parse.git'
// , toString: [Function] }
console.log(GitUrlParse("https://github.com/IonicaBizau/node-git-url-parse.git").toString("ssh"));
// => 'git@github.com:IonicaBizau/node-git-url-parse.git.git'
console.log(GitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git").toString("https"));
// => 'https://github.com/IonicaBizau/node-git-url-parse.git'Documentation
GitUrlParse(url)
Parses a Git url.
Params
- String
url: The Git url to parse.
Return
- GitUrl The
GitUrlobject containing: protocol(String): The url protocol.source(String): The Git provider (e.g."github.com").owner(String): The repository owner.name(String): The repository name._(String): The original url which was parsed.toString(Function): A function to stringify the parsed url into another url type.
stringify(obj, type)
Stringifies a GitUrl object.
Params
- GitUrl
obj: The parsed Git url object. - String
type: The type of the stringified url (defaultobj.protocol).
Return
- String The stringified url.
How to contribute
Have an idea? Found a bug? See how to contribute.
License
KINDLY © Ionică Bizău–The LICENSE file contains a copy of the license.