JSPM

  • Created
  • Published
  • Downloads 5013561
  • Score
    100M100P100Q210876F
  • License MIT

Parses and stringifies git urls.

Package Exports

  • git-url-parse

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (git-url-parse) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

git-url-parse

git-url-parse Donate now

Parses and stringifies git urls.

Installation

$ npm i git-url-parse

Example

// 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 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 (default obj.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.