git-url-parse
Parses and stringifies git urls.
Installation
$ npm i git-url-parse
Example
// Dependenciesvar GitUrlParse = ; console;// => { protocol: 'ssh'// , source: 'github.com'// , owner: 'IonicaBizau'// , name: 'node-git-url-parse'// , _: 'git@github.com:IonicaBizau/node-git-url-parse.git'// , toString: [Function] } console;// => { protocol: 'https'// , source: 'github.com'// , owner: 'IonicaBizau'// , name: 'node-git-url-parse'// , _: 'https://github.com/IonicaBizau/node-git-url-parse.git'// , toString: [Function] } console;// => 'git@github.com:IonicaBizau/node-git-url-parse.git.git' console;// => '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
GitUrl
object 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.