git-url-parse
A high level git url parser for common git providers.
Last updated a year ago by ionicabizau .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install git-url-parse 
SYNC missed versions from official npm registry.

git-url-parse

git-url-parse

Support me on Patreon Buy me a book PayPal Ask me anything Travis Version Downloads Get help on Codementor

Buy Me A Coffee

A high level git url parser for common git providers.

:cloud: Installation

# Using npm
npm install --save git-url-parse

# Using yarn
yarn add git-url-parse

:clipboard: 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/git-url-parse/blob/master/test/index.js"));
// { protocols: [ 'https' ],
//   protocol: 'https',
//   port: null,
//   resource: 'github.com',
//   user: '',
//   pathname: '/IonicaBizau/git-url-parse/blob/master/test/index.js',
//   hash: '',
//   search: '',
//   href: 'https://github.com/IonicaBizau/git-url-parse/blob/master/test/index.js',
//   token: '',
//   toString: [Function],
//   source: 'github.com',
//   name: 'git-url-parse',
//   owner: 'IonicaBizau',
//   organization: '',
//   ref: 'master',
//   filepathtype: 'blob',
//   filepath: 'test/index.js',
//   full_name: 'IonicaBizau/git-url-parse' }

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"

:question: Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.

  2. For bug reports and feature requests, open issues. :bug:

  3. For direct and quick help, you can use Codementor. :rocket:

:memo: 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.
  • ref (String): The repository ref (e.g., "master" or "dev").
  • filepath (String): A filepath relative to the repository root.
  • filepathtype (String): The type of filepath in the url ("blob" or "tree").
  • 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.
  • git_suffix (Boolean): Whether to add the .git suffix or not.

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.

:yum: How to contribute

Have an idea? Found a bug? See how to contribute.

:sparkling_heart: Support my projects

I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • Starring and sharing the projects you like :rocket:

  • Buy me a book—I love books! I will remember you after years if you buy me one. :grin: :book:

  • PayPal—You can make one-time donations via PayPal. I'll probably buy a coffee tea. :tea:

  • Support me on Patreon—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).

  • Bitcoin—You can send me bitcoins at this address (or scanning the code below): 1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6

Thanks! :heart:

:dizzy: Where is this library used?

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

  • auto-changelog-vsts (by Pete Cook)—Command line tool for generating a changelog from git tags and commit history
  • autorelease-setup (by Tyler Johnson)—A CLI tool for setting up a repository with autorelease.
  • belt-repo (by ewnd9)—repo module for belt
  • bibi (by steelbrain)—A repository management tool
  • bitbucket-pullr (by Julien Langlois)—CLI for creating Bitbucket pull request
  • branch-release (by Roman Hotsiy)—Build and tag package realease on a separate branch
  • changelog.md (by EGOIST)—Manage CHANGELOG.md so easy it hurts.
  • ci-yarn-upgrade (by taichi)—Keep NPM dependencies up-to-date with CI, providing version-to-version diff for each library
  • clipped (by IniZio)—Reduce pain of configuration to once
  • committing (by Axetroy)—commit every days
  • common-boilerplate (by TZ)—base class for boilerplate
  • complan (by Pranav Parikh)—COMPLexity ANalyzer Tool For Javascript
  • create-apex-js-app (by Daniel Frech)—Bootstrap a JavaScript app for Oracle APEX applications
  • create-openapi-repo (by Roman Hotsiy)—Generator of OpenAPI(fka Swagger) repository
  • create-sourcegraph-extension—CLI to generate the skeleton for a Sourcegraph extension
  • cz-conventional-changelog-befe (by teeeemoji)—cz adaptor for baidu BEFE
  • def-core (by tbfed)—def core for deflite
  • docula-ui—Express.js bindings for Docula project
  • docula-ui-express—Express.js bindings for Docula project
  • documentation (by Tom MacWright)—a documentation generator
  • documentation-custom-markdown (by Tom MacWright)—a documentation generator
  • documentation-fork (by Tom MacWright)—a documentation generator
  • documentation-habitlab (by Tom MacWright)—a documentation generator
  • download-repo-cli (by EGOIST)—CLI tool to download GitHub repo.
  • gd-cli (by Sylvain Baronnet)—GD Command Line Interface
  • generate-preview (by Sassoun Derderian)—Get a preview from a git branch before publishing your npm package
  • generator-ckeditor4 (by Marek Lewandowski)—Yeoman generator for CKEditor 4
  • generator-clearphp (by Joschi Kuphal)—Scaffold for Composer based PHP projects with a lot of integrations, advocating the use of The Clear Architecture (https://jkphl.is/articles/clear-architecture-php)
  • 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-cherry-fix—> helps you get your fixes to another branch by cherry-picking them
  • git-issues (by Gabriel Petrovay)—Git issues extension to list issues of a Git project
  • git-lab-cli—gitlab-cli ==================
  • git-signed (by Marc Trudel)—git commit signing made easy (and enforceable)
  • git-source—Parse and stringify git urls in a friendly way.
  • git-upstream (by Leko)—Utility to set the remote "upstream" on forked repository
  • git-url-promise (by Evgeniy Shershnev)—Git url promise
  • 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
  • gitc (by Cezar Luiz)—Manage your pull requests and issues from your command line.
  • github-publish-npm (by Ofer Sadgat)—This will upload publish npm assets to the GitHub Releases API.
  • gitlab-ci-variables-cli (by Khoa Tran)—CLI tool to set/get pipeline variables on Gitlab CI.
  • gitlab-tool-cli—gitlab-tool-cli ==================
  • gitline (by Cezar Luiz)—Manage your pull requests and issues from your command line.
  • gtni (by Nur Rony)—Install your all npm dependencies recursively with gtni while you are doing git clone, fetch or pull
  • gub (by janry)—> 接入成本极低,快速从原有项目(可运行项目)中clone出新项目,并重写package.json,安装依赖
  • harry-reporter—Reporter plugin for hermione
  • just-dev-sdk (by zoujie.wzj)—just development sdk
  • kef-core (by younth)—The awesome KEF
  • konitor (by Simon Constans)—The command-line tool for monitoring konnectors
  • lcov-server (by Gabriel J. Csapo)—???? A simple lcov server & cli parser
  • miguelcostero-ng2-toasty (by Sergey Akopkokhyants)—Angular2 Toasty component shows growl-style alerts and messages for your web app
  • moto-connector (by limingv5)—JAN平台SDK
  • node-norman (by zenwarr)—A tool to develop multi-package Node.js apps with ease.
  • 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.
  • one-more-gitlab-cli (by Christophe Hamerling)—One more Gitlab CLI
  • 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
  • semantic-release-gitmoji (by MomoCow)—Different from conventional changelog, Gitmoji commits are used to determine a release type and generate release notes.
  • sherry-utils (by ULIVZ)—sherry-utils for Sherry
  • 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
  • snipx—Best team snippets
  • ssh-remote—Automagically switch on the SSH remote url in a Git repository.
  • strapper (by Sam Newman)—Coming Soon
  • testarmada-midway (by Himanshu Jain)—Mocking server to create reliable test data for test execution and development
  • vscode-gpm—Git Project Manager
  • yarn-upgrade-on-ci (by htwroclau)—undefined

:scroll: License

MIT © Ionică Bizău

Current Tags

  • 11.1.2                                ...           latest (a year ago)

42 Versions

  • 11.1.2                                ...           a year ago
  • 11.1.1                                ...           a year ago
  • 11.1.0                                ...           a year ago
  • 11.0.1                                ...           a year ago
  • 11.0.0                                ...           a year ago
  • 10.1.0                                ...           a year ago
  • 10.0.1                                ...           a year ago
  • 9.0.1                                ...           2 years ago
  • 9.0.0                                ...           2 years ago
  • 8.3.1                                ...           2 years ago
  • 8.3.0                                ...           2 years ago
  • 8.2.0                                ...           2 years ago
  • 8.1.0                                ...           2 years ago
  • 8.0.1                                ...           2 years ago
  • 8.0.0                                ...           2 years ago
  • 7.2.0                                ...           2 years ago
  • 7.1.0                                ...           2 years ago
  • 7.0.2                                ...           2 years ago
  • 7.0.1                                ...           2 years ago
  • 7.0.0                                ...           3 years ago
  • 6.2.2                                ...           3 years ago
  • 6.2.1                                ...           3 years ago
  • 6.2.0                                ...           3 years ago
  • 6.1.1                                ...           3 years ago
  • 6.1.0                                ...           3 years ago
  • 6.0.7                                ...           3 years ago
  • 6.0.6                                ...           3 years ago
  • 6.0.5                                ...           3 years ago
  • 6.0.4                                ...           3 years ago
  • 6.0.3                                ...           4 years ago
  • 6.0.2                                ...           4 years ago
  • 6.0.1                                ...           4 years ago
  • 6.0.0                                ...           4 years ago
  • 5.0.1-beta                                ...           4 years ago
  • 5.0.1                                ...           4 years ago
  • 5.0.0                                ...           4 years ago
  • 4.2.1                                ...           4 years ago
  • 4.2.0                                ...           4 years ago
  • 4.1.0                                ...           4 years ago
  • 4.0.0                                ...           4 years ago
  • 3.0.0                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 575
This Week 17,662
This Month 36,044
Last Day 1,122
Last Week 17,645
Last Month 55,353
Dependencies (1)
Dev Dependencies (1)
Dependents (203)

Copyright 2014 - 2016 © taobao.org |