What is git-url-parse?
The git-url-parse npm package is a utility for parsing Git URLs and extracting useful information from them. It supports various Git URL formats and provides methods to manipulate and retrieve different parts of the URL.
What are git-url-parse's main functionalities?
Parsing a Git URL
This feature allows you to parse a Git URL and get an object containing various parts of the URL such as the protocol, source, owner, name, and more.
const gitUrlParse = require('git-url-parse');
const parsed = gitUrlParse('https://github.com/IonicaBizau/git-url-parse.git');
console.log(parsed);
Extracting the owner and name
This feature allows you to extract specific parts of the Git URL, such as the owner and repository name.
const gitUrlParse = require('git-url-parse');
const parsed = gitUrlParse('https://github.com/IonicaBizau/git-url-parse.git');
console.log(parsed.owner); // 'IonicaBizau'
console.log(parsed.name); // 'git-url-parse'
Converting to a different URL format
This feature allows you to convert a Git URL from one format to another, such as from HTTPS to SSH.
const gitUrlParse = require('git-url-parse');
const parsed = gitUrlParse('https://github.com/IonicaBizau/git-url-parse.git');
const sshUrl = parsed.toString('ssh');
console.log(sshUrl); // 'git@github.com:IonicaBizau/git-url-parse.git'
Other packages similar to git-url-parse
parse-github-url
The parse-github-url package is a utility for parsing GitHub URLs specifically. It extracts information such as the owner, repository name, and branch. Compared to git-url-parse, it is more focused on GitHub URLs and may not support other Git hosting services.
git-url
The git-url package provides similar functionality for parsing and manipulating Git URLs. It offers methods to extract parts of the URL and convert between different URL formats. It is comparable to git-url-parse in terms of functionality but may have different API design and usage patterns.
url-parse
The url-parse package is a more general-purpose URL parsing library that can handle various types of URLs, not just Git URLs. While it can be used to parse Git URLs, it does not provide Git-specific methods and properties like git-url-parse does.
git-url-parse
A high level git url parser for common git providers.
:cloud: Installation
npm install --save git-url-parse
yarn add git-url-parse
:clipboard: Example
const GitUrlParse = require("git-url-parse");
console.log(GitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git"));
console.log(GitUrlParse("https://github.com/IonicaBizau/node-git-url-parse.git"));
console.log(GitUrlParse("https://github.com/IonicaBizau/git-url-parse/blob/master/test/index.js"));
console.log(GitUrlParse("https://github.com/IonicaBizau/node-git-url-parse.git").toString("ssh"));
console.log(GitUrlParse("git@github.com:IonicaBizau/node-git-url-parse.git").toString("https"));
:question: Get Help
There are few ways to get help:
- Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
- For bug reports and feature requests, open issues. :bug:
- 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:
-
—I love books! I will remember you after years if you buy me one. :grin: :book:
-
—You can make one-time donations via PayPal. I'll probably buy a coffee tea. :tea:
-
—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
@backstage/backend-common
@plone/scripts
@atomist/automation-client
@storybook/storybook-deployer
@backstage/integration
@pvm/core
@kadira/storybook-deployer
workspace-tools
gatsby-source-git
@backstage/plugin-catalog-backend
@backstage/plugin-scaffolder-backend
@lerna-lite/core
umi-build-dev
@nuxt/telemetry
@era-ci/utils
@atomist/automation-client-ext-raven
git-source
semantic-release-gitmoji
@qiwi/semantic-release-gh-pages-plugin
@atomist/sdm-pack-analysis
apify-shared
@git-stack/server-core
remax-stats
strapi-generate-new
common-boilerplate
renovate
@backstage/plugin-techdocs-node
@s-ui/studio
@instructure/ui-scripts
@appworks/project-utils
@jswork/next-git-url
@umijs/block-sdk
@lerna/github-client
@micro-app/shared-utils
@oumi/block-sdk
@radjs/block-sdk
@wetrial/block-sdk
datoit-generate-new
@appirio/appirio
@backstage/plugin-techdocs
@log4brains/core
@xdn/cli
@atomist/skill
@koumoul/gh-pages-multi
@zeplin/cli
@pvm/gitlab
@atomist/cli
@brisk-docs/gatsby-generator
@microservices/cli
@vamsikc/plugin-catalog
hzero-block-sdk
@spryker-lerna/github-client
gitbook-start-plugin-iaas-ull-es-noejaco2017
omg
clipped
fotingo
git-issues
@stackbit/dev-common
@guardian/cdk
lambda-service
octokit-downloader
stylelint-formatter-utils
sync-repos
@enkeledi/react-native-week-month-date-picker
copy-github-directory
@kevinbds/techdocs-common
docula-ui
@s-ui/mono
@facadecompany/ignition-ui
@focusworkstemp/project-utils
@git-stack/hemera-plugin
@jaredpalmer/workspace-tools
@unibtc/release-it
scaffolder-core
testarmada-midway
autorelease-setup
@geut/git-url-parse
@erquhart/lerna-github-client
@oumi/cli-ui
wiby
sherry-utils
changelog.md
@yarnpkg/plugin-git
@pubbo/github-client
@sanv/apify-shared
@0x-lerna-fork/github-client
@atomist/uhura
@pmworks/project-utils
@feizheng/next-git-url
@hygiene/plugin-github-url
@iceworks/project-utils
gcpayz-block-sdk
generator-clearphp
documentation-custom-markdown
@antv/gatsby-theme-antv
@backstage/plugin-scaffolder
@scafflater/scafflater
@brisk-docs/website
@buschtoens/documentation
@dandean/storybook-deployer
@emedvedev/renovate
@dougkulak/semantic-release-gh-pages-plugin
@hemith/react-native-tnk
@hugomrdias/documentation
@pageshare/cli
@merna/github-client
@lerna-test-v1/markdown
@jswork/topics2keywords
@pvdlg/semantic-release
@rianfowler/backstage-backend-common
auto-changelog-vsts
@deskbtm/workspace-tools
debone
cz-conventional-changelog-befe
create-apex-js-app
gatsby-source-git-remotes
gatsby-source-npmjs
flutter-boot
fster
gatsby-theme-zh
git-service-node
git-origin-check
git-yoink
harry-reporter
jsnix
kef-core
konitor
laborious
l-other-data
lime-cli
npm_one_1_2_3
miguelcostero-ng2-toasty
mdnext-loader
native-kakao-login
open-pull-request
rn-adyen-dropin
simple-github-release
snipx
react-native-contact-list
react-native-biometric-authenticate
react-native-arunmeena1987
react-native-is7
react-native-kakao-maps
react-native-my-first-try-arun-ramya
react-native-payu-payment-testing
quinntainer
qts-fission
react-native-ytximkit
release-it-http
spk
@mmomtchev/documentation
tooling-personal
todo2issue
vuepress-plugin-remote-url
tmplr
gitlab-ci-variables-cli
gtni
gitc
gitbook-start-iaas-bbdd-alex-moi
gitbook-start-iaas-ull-es-merquililycony
lcov-server
@cliz/gpm
docula-ui-express
prep-barv11
@axetroy/gpm
@belt/repo
belt-repo
@geut/git-compare-template
@gasket/plugin-metrics
cover-builder
@positionex/position-sdk
ewizard-cli
@1coin178/github-compare
@arcanis/sherlock
@cilyn/bitbucket
@corelmax/react-native-my2c2p-sdk
@csmith/release-it
@esops/publish-github-pages
@felipesimmi/react-native-datalogic-module
@narfeta/catalog-backend
@hawkingnetwork/react-native-tab-view
@infinitecsolutions/storybook-deployer
@pipelinedoc/cli
ftl-renovate
gatsby-theme-cone
gatsby-theme-nestx
generate-github-directory
git-url-promise
git-observer
github-action-readme
coc-discord-rpc
@xyz/create-package
@theowenyoung/gatsby-source-git
@voodeng/uppacks
bitbucket-pullr
configorama
drowl-base-theme-iconset
dx-scanner
native-apple-login
react-native-cplus
npm_qwerty
patchanon-cli
pbc
wsj.gatsby-source-git
semantic-release-github-milestones
tldw
react-native-arunjeyam1987
publish-version
generator-openapi-repo
github-publish-npm
pr-log
complan
@shopgate/pwa-releaser
react-native-bubble-chart
@geut/chan-parser
@evanpurkhiser/tooling-personal
@blackglory/git-list
nmrium-cli
github-assistant
@tmplr/node
react-native-flyy
@stackbit/cli
@edgio/cli
@react-18-pdf/root
@wekanteam/documentation
@1nd/documentation
@amorist/gatsby-theme-antd
@apardellass/react-native-audio-stream
@campus-online/gatsby-source-git
@carrotwu/wcli
@docomodigital/pdor
@cyber-tools/cyber-npm
@cratosw/gatsby-antd
@domestika/mono
@git-stack/module-server
@geeky-apo/react-native-advanced-clipboard
@lerna-test-v1/git
@patrickhulce/scripts
@saad27/react-native-bottom-tab-tour
@tjmonsi/generator-uplb-hci-lab-project-template
@tjmonsi/generator-project-template
@vicoders/cli2
@voodeng/archive
auto-clone
aral-vps-test
cirodown
candlelabssdk
canarist
@tagoro9/git
committing
detect-node-support
gatsby-theme-art-graph
generator-bootstrap-boilerplate-template
gatsby-theme-cone-oc
@turborepo/workspace-tools
git-imitate
github-books
git-upstream
react-native-dsphoto-module
react-native-responsive-size
react-native-sayhello-module
learning-journal-ci
just-dev-sdk
meta-release
nixitech_cli
openapi-repo-generator
npm_one_12_34_1_
npm_one_2_2
payutesting
sn-flutter-boot
umi-plugin-repo
wp-continuous-deployment
@axetroy/git-clone
branch-release
semantic-release-telegram
gatsby-theme-iot
download-repo-cli
gd-cli
gitbook-start-iaas-ull-es-alex-moi
gitline
documentation-markdown-themes
@con-test/react-native-concent-common
yarn-upgrade-on-ci
@dvcorg/cml
react-native-shekhar-bridge-test
react-feedback-sdk
@oiti/documentoscopy-react-native
generate-preview
@pvm/github
@kb-sanity/proto-kb-plugin
@stagas/documentation-fork
@jupiterone/graph-checkmarx
@gogogosir/build-cli
@backstage/plugin-techdocs-module-addons-contrib
@layer0/cli
@activeviam/documentation
@mayahq/mayadev
@pagedip/tool-autorelease
@elestu/actions-dependacop
@epranka/create-tsx-package
@githubtraining/github-exercise-manager
@hnp/package-scripts
@hjin/generator-app
@stavalfi/ci
birken-react-native-community-image-editor
cetus-cli
@shushuer/cli
create-release-it
create-sourcegraph-extension
gatsby-theme-hansin
git-multi-profile
gitlab-tool-cli
luojia-cli-dev
mdxbook
myrenobatebot
node-norman
reac-native-arun-ramya-test
react-native-plugpag-wrapper
react-native-pulsator-native
react-native-arun-ramya-test
react-native-arunramya151
react-native-transtracker-library
@s-ui/changelog
vscode-gpm
sinanews-flutter-boot
vuepress-theme-next
bridgewwater-cli
@kevinbds/plugin-techdocs
@wpbrothers/sbcli
@alitajs/block-sdk
ourbigbook
ci-yarn-upgrade
bibi
gitbook-start-https-alex-moi
mira
moto-connector
nodeschool-admin
ogh
one-more-gitlab-cli
ship-release
ssh-remote
strapper
@jfilipe-sparta/react-native-module_2
@rocket.chat/houston
@saleor/cli
cogoportutils
airbyte-faros-destination
release2hub
cc-flow
kube-workflow
@backstage/plugin-catalog-import
@cythral/renovate
@epranka/create-package
@generates/kdot
@georgs/beachball
@limejs/cli
@bcgov/gatsby-source-github-raw
@atomist/ci-sdm
@makepad/puppeteer-cli
@mockswitch/cli
@rescribe/cli
@pubcore/node-docker-build
@reshiftsecurity/reshift-plugin-npm
@tahini/nc
@senti-techlabs/generator-senti-project-template
@whey/gatsby-theme-whey
@zpmpkg/zpm
@zalando-backstage/plugin-catalog
air-material_cli
actions-package-update
angularvezba
aral-server
astra-ufo-sdk
blog-flutter-boot
react-native-syan-photo-picker
@wecraftapps/react-native-use-keyboard
documentation-fork
documentation42
create-n
gatsby-source-github-raw
git-csv
git-cherry-fix
git-push-pr
kit-command
l2forlerna
next-mdx-books
myrenovatebot
native-google-login
private-beachball
raact-native-arunramya151
:scroll: License
MIT © Ionică Bizău