git-url-parse
A high level git url parser for common git providers.
Last updated 13 days 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:

  • release-it
  • documentation
  • apollo
  • @atomist/automation-client
  • @storybook/storybook-deployer
  • @kadira/storybook-deployer
  • gatsby-source-git
  • @atomist/automation-client-ext-raven
  • umi-build-dev
  • git-source
  • @atomist/sdm-pack-analysis
  • @qiwi/semantic-release-gh-pages-plugin
  • @git-stack/server-core
  • @nuxt/telemetry
  • @lerna/github-client
  • @umijs/block-sdk
  • @instructure/ui-scripts
  • lambda-service
  • @wetrial/block-sdk
  • hzero-block-sdk
  • @micro-app/shared-utils
  • remax-stats
  • beachball
  • workspace-tools
  • gitbook-start-plugin-iaas-ull-es-noejaco2017
  • autorelease-setup
  • documentation-custom-markdown
  • @hygiene/plugin-github-url
  • sherry-utils
  • @unibtc/release-it
  • clipped
  • @erquhart/lerna-github-client
  • @0x-lerna-fork/github-client
  • common-boilerplate
  • @atomist/uhura
  • @brisk-docs/website
  • @hawkingnetwork/react-native-tab-view
  • miguelcostero-ng2-toasty
  • docula-ui
  • @brisk-docs/gatsby-generator
  • @microservices/cli
  • @atomist/cli
  • stylelint-formatter-utils
  • omg
  • sync-repos
  • @facadecompany/ignition-ui
  • @geut/git-url-parse
  • @temporg/rds-scripts
  • @koumoul/gh-pages-multi
  • @feizheng/next-git-url
  • @yarnpkg/plugin-git
  • semantic-release-gitmoji
  • @git-stack/hemera-plugin
  • @s-ui/mono
  • @adminide-stack/git-api-browser
  • @xdn/cli
  • committing
  • gitbook-start-https-alex-moi
  • gitbook-start-iaas-ull-es-merquililycony
  • proyecto-sytw-alex-moi
  • gitbook-start-iaas-ull-es-alex-moi
  • gitbook-start-iaas-bbdd-alex-moi
  • complan
  • @axetroy/git-clone
  • generator-cleanphp
  • @axetroy/gpmx
  • generator-ckeditor4
  • documentation-habitlab
  • nodeschool-admin
  • one-more-gitlab-cli
  • def-core
  • gd-cli
  • sinit
  • strapper
  • smart-clone
  • github-publish-npm
  • download-repo-cli
  • generator-nm-bti
  • ogh
  • gitline
  • gitc
  • gitlab-ci-variables-cli
  • gitlab-ci-variables-setter-cli
  • documentation-fork
  • generator-openapi-repo
  • git-url-promise
  • kef-core
  • @axetroy/gpm
  • @pvdlg/semantic-release
  • gitlab-tool-cli
  • yarn-upgrade-on-ci
  • snipx
  • @hjin/generator-app
  • @reframe/github-pages
  • belt-repo
  • @esops/publish-github-pages
  • @hugomrdias/documentation
  • git-signed
  • @activeviam/documentation
  • just-dev-sdk
  • cz-conventional-changelog-befe
  • create-apex-js-app
  • @voodeng/archive
  • @voodeng/uppacks
  • auto-changelog-vsts
  • harry-reporter
  • @campus-online/gatsby-source-git
  • gtni
  • ci-yarn-upgrade
  • generator-clearphp
  • openapi-repo-generator
  • git-imitate
  • vscode-gpm
  • @atomist/ci-sdm
  • documentation42
  • @limejs/cli
  • lime-cli
  • laborious
  • release-it-http
  • bibi
  • lcov-server
  • create-release-it
  • git-service-node
  • @infinitecsolutions/storybook-deployer
  • @1nd/documentation
  • branch-release
  • git-cherry-fix
  • vuepress-plugin-remote-url
  • gatsby-source-github-raw
  • moto-connector
  • @zpmpkg/zpm
  • konitor
  • release2hub
  • @geut/git-compare-template
  • @geut/chan-parser
  • git-observer
  • docula-ui-express
  • sn-flutter-boot
  • spk
  • umi-plugin-repo
  • @epranka/create-tsx-package
  • flutter-boot
  • node-norman
  • air-material_cli
  • @belt/repo
  • remote-commit-url
  • @arcanis/sherlock
  • @dandean/storybook-deployer
  • git-upstream
  • configorama
  • @cratosw/gatsby-antd
  • @pubcore/node-docker-build
  • @tjmonsi/generator-uplb-hci-lab-project-template
  • @tagoro9/git
  • tldw
  • gatsby-theme-hansin
  • @temporg/ui-scripts
  • generate-preview
  • aral-vps-test
  • bitbucket-pullr
  • @s-ui/changelog
  • @whey/gatsby-theme-whey
  • @docomodigital/pdor
  • auto-clone
  • create-sourcegraph-extension
  • create-n
  • aral-server
  • gatsby-source-git-remotes
  • @pagedip/tool-autorelease
  • documentation-markdown-themes
  • @shopgate/pwa-releaser
  • @vicoders/cli2
  • @stavalfi/ci
  • @amorist/gatsby-theme-antd
  • cirodown
  • @apardellass/react-native-audio-stream
  • gatsby-theme-cone
  • changelog.md
  • wp-continuous-deployment
  • gatsby-source-npmjs
  • l2forlerna
  • detect-node-support
  • @patrickhulce/scripts
  • @cilyn/bitbucket
  • meta-release
  • react-native-plugpag-wrapper
  • @cyber-tools/lib-cli
  • @feizheng/git-url-cli
  • @myetherwallet/mew-components
  • @hnp/package-scripts
  • git-csv
  • ship-release
  • ssh-remote
  • @senti-techlabs/generator-senti-project-template
  • canarist
  • @gasket/plugin-metrics
  • actions-package-update
  • kit-command
  • @tahini/nc
  • @epranka/create-package
  • @bcgov/gatsby-source-github-raw
  • @theowenyoung/gatsby-source-git
  • git-lab-cli
  • git-push-pr
  • lage
  • cc-flow
  • react-native-pulsator-native
  • @csmith/release-it
  • query-registry
  • @s-ui/ci
  • @git-stack/module-server
  • cetus-cli
  • generate-github-directory
  • @s-ui/ssr
  • fotingo
  • mira
  • @backstage/plugin-scaffolder-backend
  • @backstage/plugin-techdocs-backend
  • @rescribe/cli
  • kaskadi-cli
  • @antv/gatsby-theme-antv
  • sinanews-flutter-boot
  • dx-scanner
  • rollman
  • pr-log
  • git-issues

:scroll: License

MIT © Ionică Bizău

Current Tags

  • 11.2.0                                ...           latest (13 days ago)

44 Versions

  • 11.2.0                                ...           13 days ago
  • 11.1.3                                ...           a month ago
  • 11.1.2                                ...           2 years ago
  • 11.1.1                                ...           2 years ago
  • 11.1.0                                ...           2 years ago
  • 11.0.1                                ...           2 years ago
  • 11.0.0                                ...           2 years ago
  • 10.1.0                                ...           2 years ago
  • 10.0.1                                ...           2 years 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                                ...           3 years ago
  • 8.1.0                                ...           3 years ago
  • 8.0.1                                ...           3 years ago
  • 8.0.0                                ...           3 years ago
  • 7.2.0                                ...           3 years ago
  • 7.1.0                                ...           3 years ago
  • 7.0.2                                ...           3 years ago
  • 7.0.1                                ...           3 years ago
  • 7.0.0                                ...           3 years ago
  • 6.2.2                                ...           3 years ago
  • 6.2.1                                ...           3 years ago
  • 6.2.0                                ...           4 years ago
  • 6.1.1                                ...           4 years ago
  • 6.1.0                                ...           4 years ago
  • 6.0.7                                ...           4 years ago
  • 6.0.6                                ...           4 years ago
  • 6.0.5                                ...           4 years ago
  • 6.0.4                                ...           4 years ago
  • 6.0.3                                ...           4 years ago
  • 6.0.2                                ...           4 years ago
  • 6.0.1                                ...           5 years ago
  • 6.0.0                                ...           5 years ago
  • 5.0.1-beta                                ...           5 years ago
  • 5.0.1                                ...           5 years ago
  • 5.0.0                                ...           5 years ago
  • 4.2.1                                ...           5 years ago
  • 4.2.0                                ...           5 years ago
  • 4.1.0                                ...           5 years ago
  • 4.0.0                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 85
This Week 29,450
This Month 104,032
Last Day 6,869
Last Week 42,225
Last Month 163,083
Dependencies (1)
Dev Dependencies (1)
Dependents (266)

Copyright 2014 - 2016 © taobao.org |