jgrosso / git-url-parse

:v: A high level git url parser for common git providers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git-url-parse

git-url-parse

Patreon PayPal AMA Travis Version Downloads Get help on Codementor

A high level git url parser for common git providers.

☁️ Installation

$ npm i --save git-url-parse

📋 Example

// Dependencies
const GitUrlParse = require("git-url-parse");

console.log(GitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git"));
// => {
//     protocols: []
//   , port: null
//   , resource: "github.com"
//   , user: "git"
//   , pathname: "/IonicaBizau/node-git-url-parse.git"
//   , hash: ""
//   , search: ""
//   , href: "git@github.com:IonicaBizau/node-git-url-parse.git"
//   , token: ""
//   , protocol: "ssh"
//   , toString: [Function]
//   , source: "github.com"
//   , name: "node-git-url-parse"
//   , owner: "IonicaBizau"
// }

console.log(GitUrlParse("https://github.com/IonicaBizau/node-git-url-parse.git"));
// => {
//     protocols: ["https"]
//   , port: null
//   , resource: "github.com"
//   , user: ""
//   , pathname: "/IonicaBizau/node-git-url-parse.git"
//   , hash: ""
//   , search: ""
//   , href: "https://github.com/IonicaBizau/node-git-url-parse.git"
//   , token: ""
//   , protocol: "https"
//   , toString: [Function]
//   , source: "github.com"
//   , name: "node-git-url-parse"
//   , owner: "IonicaBizau"
// }

console.log(GitUrlParse("https://github.com/IonicaBizau/node-git-url-parse.git").toString("ssh"));
// => "git@github.com:IonicaBizau/node-git-url-parse.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:
  • protocols (Array): An array with the url protocols (usually it has one element).
  • port (null|Number): The domain port.
  • resource (String): The url domain (including subdomains).
  • user (String): The authentication user (usually for ssh urls).
  • pathname (String): The url pathname.
  • hash (String): The url hash.
  • search (String): The url querystring value.
  • href (String): The input url.
  • protocol (String): The git url protocol.
  • token (String): The oauth token (could appear in the https urls).
  • source (String): The Git provider (e.g. "github.com").
  • owner (String): The repository owner.
  • name (String): The repository name.
  • full_name (String): The owner and name values in the owner/name format.
  • toString (Function): A function to stringify the parsed url into another url type.
  • organization (String): The organization the owner belongs to. This is CloudForge specific.

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.

💰 Donations

Another way to support the development of my open-source modules is to set up a recurring donation, via Patreon. 🚀

PayPal donations are appreciated too! Each dollar helps.

Thanks! ❤️

💫 Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

  • autorelease-setup (by Tyler Johnson)—A CLI tool for setting up a repository with autorelease.
  • branch-release (by Roman Hotsiy)—Build and tag package realease on a separate branch
  • ci-yarn-upgrade (by taichi)—Keep NPM dependencies up-to-date with CI, providing version-to-version diff for each library
  • complan (by Pranav Parikh)—COMPLexity ANalyzer Tool For Javascript
  • docula-ui-express—Express.js bindings for Docula project
  • documentation (by Tom MacWright)—a documentation generator
  • download-repo-cli (by EGOIST)—CLI tool to download GitHub repo.
  • generator-nm-bti (by Tyler Johnson)—Scaffold out a node module, Beneath the Ink style.
  • generator-openapi-repo (by Roman Hotsiy)—Yeoman generator for OpenAPI(fka Swagger) repo to help you share spec for your API
  • git-issues (by Gabriel Petrovay)—Git issues extension to list issues of a Git project
  • git-source—Parse and stringify git urls in a friendly way.
  • gitbook-start-https-alex-moi (by Moises Yanes Carballo)—Plugin deploy iaas https
  • gitbook-start-iaas-bbdd-alex-moi (by Moises Yanes Carballo)—Plugin deploy iaas bbdd
  • gitbook-start-iaas-ull-es-alex-moi (by Moises Yanes Carballo)—Plugin deploy maquina iaas-ull-es
  • gitbook-start-iaas-ull-es-merquililycony (by Constanza León, Merquis Cruz, Liliana Galiano)—El objetivo de esta práctica es extender el package NodeJS publicado en npm en una práctica anterior con una nueva funcionalidad que permita que los usuarios realizar un despliegue automatico en el servidor de IAAS
  • gitbook-start-plugin-iaas-ull-es-noejaco2017 (by alu0100622492)—Despliegue plugin Iaas
  • github-publish-npm (by Ofer Sadgat)—This will upload publish npm assets to the GitHub Releases API.
  • gtni (by Nur Mohammed Rony)—Install your all npm dependencies recursively with gtni while you are doing git clone, fetch or pull
  • nodeschool-admin (by Martin Heidegger)—CLI tool for setting up and maintaining a nodeschool chapters and other things.
  • ogh (by EGOIST)—Open GitHub Page of your repo directly in Terminal.
  • pr-log (by Mathias Schreck)—Changelog generator based on GitHub Pull Requests
  • proyecto-sytw-alex-moi (by Moises Yanes Carballo)—Module to build a book on GitBook
  • ship-release—Publish new versions on GitHub and npm with ease.
  • sinit (by villadora)—Project initializer based on Scaffold
  • smart-clone—Clone a directory into a Golang style directory structure
  • ssh-remote—Automagically switch on the SSH remote url in a Git repository.
  • strapper (by Sam Newman)—Coming Soon

📜 License

MIT © Ionică Bizău

About

:v: A high level git url parser for common git providers.

License:MIT License


Languages

Language:JavaScript 100.0%