git-url-parse v16.0.1
git-url-parse
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:
- 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, refs)
Parses a Git url.
Params
- String
url: The Git url to parse. - Array
refs: An array of strings representing the refs. This is helpful in the context of the URLs that contain branches with slashes. If user wants to identify the branch, he should pass all branch names of the project as part of refs parameter
Return
- GitUrl The
GitUrlobject 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 theowner/nameformat.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.gitsuffix 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 (defaultobj.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
coffeetea. :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:
@0x-lerna-fork/github-client@1coin178/github-compare@_nomtek/react-native-shimmer-animation@adityasinghal26/backstage-plugin-daytona@akemona-org/strapi-generate-new@amiruldev/wajs@anakz/backstage-plugin-library-check-backend@antv/gatsby-theme-antv@appirio/appirio@appworks/project-utils@arcanis/sherlock@ashcorrguardian/cdk@atomist/automation-client@atomist/automation-client-ext-raven@atomist/cli@atomist/sdm-pack-analysis@atomist/skill@atomist/uhura@axetroy/gpm@backstage-community/plugin-github-actions@backstage/backend-common@backstage/backend-defaults@backstage/cli@backstage/integration@backstage/plugin-catalog-backend@backstage/plugin-catalog-backend-module-github@backstage/plugin-catalog-import@backstage/plugin-github-actions@backstage/plugin-scaffolder@backstage/plugin-scaffolder-backend-module-confluence-to-markdown@backstage/plugin-techdocs@backstage/plugin-techdocs-module-addons-contrib@backstage/plugin-techdocs-node@belt/repo@blackglory/git-list@brisk-docs/gatsby-generator@brisk-docs/website@buschtoens/documentation@cilyn/bitbucket@ckatzorke/renovate@cliz/gpm@codemod.com/workflow@corelmax/react-native-my2c2p-sdk@cs6/react-native-test-native-view-library@csmith/release-it@ctdesarrollo/pack-up@dandean/storybook-deployer@daytona-io/backstage-plugin-daytona@deskbtm/workspace-tools@dfatwork-pkgs/backstage-cli@dougkulak/semantic-release-gh-pages-plugin@drakedeatonuk/rschedule@dtwo/telemetry@eat-fish/changelog@emedvedev/renovate@enkeledi/react-native-week-month-date-picker@env0/backstage-plugin-env0@era-ci/utils@erquhart/lerna-github-client@esops/publish-github-pages@eteg/nextra-theme-docs@facadecompany/ignition-ui@feizheng/next-git-url@felipesimmi/react-native-datalogic-module@flxbl-io/sfp@focusworkstemp/project-utils@form8ion/lift@gasket/plugin-metrics@geut/chan-parser@geut/git-compare-template@geut/git-url-parse@git-stack/hemera-plugin@git-stack/server-core@guardian/cdk@hawkingnetwork/react-native-tab-view@hbglobal/react-native-actions-shortcuts@hemith/react-native-tnk@holipoly/cli@hugomrdias/documentation@hygiene/plugin-github-url@iceworks/project-utils@infinitecsolutions/storybook-deployer@janus-idp/backstage-plugin-topology@jaredpalmer/workspace-tools@jswork/next-git-url@jswork/topics2keywords@kadira/storybook-deployer@kevinbds/techdocs-common@kgit/readbility@koumoul/gh-pages-multi@labiebhn_/react-native-multiplier@lehuyaa/my-assets@lerna-lite/version@lerna-test-v1/markdown@lerna/create@lerna/github-client@lerna/legacy-package-management@log4brains/core@madm4ttus3r/l4bcore@merna/github-client@micro-app/shared-utils@microservices/cli@mmomtchev/documentation@mongchhi/plugin-blocks@monokle/synchronizer@narfeta/catalog-backend@navabi/react-native-ssl-pinning@nuxt/content@nuxt/telemetry@nuxt/ui-pro@nuxthq/studio@oumi/block-sdk@oumi/cli-ui@pageshare/cli@parallelnft/web3modal@pipelinedoc/cli@plone/scripts@pmworks/project-utils@polearn/core@positionex/position-sdk@praella/localisationist@pubbo/github-client@pubgcorp/semantic-release-gitlabmonorepo@pvdlg/semantic-release@pvm/core@qiwi/semantic-release-gh-pages-plugin@qoopido/lerna.version@radjs/block-sdk@rdfrontier/plugin-mobile@react-18-pdf/root@rianfowler/backstage-backend-common@rnx-kit/build@roadiehq/backstage-plugin-github-insights@roadiehq/backstage-plugin-github-pull-requests@roadiehq/backstage-plugin-security-insights@rocali/apollo@s-ui/mono@s-ui/ssr@s-ui/studio@safaricom/strapi@safely-project/safely-ts@salla.sa/cli@sanity/pkg-utils@sanv/apify-shared@scafflater/scafflater@secustor/backstage-plugin-renovate-common@servable/manifest@servable/tools@shopgate/pwa-releaser@sobird/actions@speakeasy-sdks/nextra-theme-docs@spotify/backstage-plugin-soundcheck-backend-module-gitlab@spryker-lerna/github-client@ssaitho/nextra-theme-docs@stackbit/cms-git@stackbit/dev-common@status-im/react-native-transparent-video@stepsec/release@storybook/storybook-deployer@strapi/pack-up@strapi/sdk-plugin@strapi/strapi@tahul/ui-fix@taingo97/react-native-sunmi-printer@taingo97/react-native-telpo-printer@tasenor/common-node@terasky/backstage-plugin-crossplane-claim-updater@theowenyoung/gatsby-source-git@tmplr/node@toanz/strapi-generate-new@umijs/block-sdk@unibtc/release-it@useoptic/optic@vamsikc/plugin-catalog@veecode-platform/plugin-github-actions@visulima/nextra-theme-docs@voodeng/uppacks@vrabbi/plugin-scaffolder@vrabbi/plugin-scaffolder-backend@wetrial/block-sdk@whhjdi/nextra-theme-docs@wolfy1339/gatsby-source-git@x-team/strapi-generate-new@xdn/cli@xyz/create-package@yarnpkg/plugin-git@zeplin/clianakketigaanaklanangteaanakwadonteaapify-sharedapolloauto-changelog-vstsautorelease-setupbelt-repobiometric-stbitbucket-pullrchangelog.mdcheckbox-componentclippedcodesandbox-theme-docscommon-boilerplatecopy-github-directorycover-buildercreate-apex-js-appcreate-release-itcz-conventional-changelog-befedatoit-generate-newdebonedef-coredevelopment-efficiencydocula-uidocula-ui-expressdocumentationdocumentation-custom-markdowndx-scannerewizard-clifluent.adflow.reactnativesdk-alphaflutter-bootfmslfotingoframework_test_library_sixdeefsterftl-renovategatsby-source-gitgatsby-source-git-remotesgatsby-source-npmjsgatsby-theme-conegatsby-theme-nestxgatsby-theme-zhgaurav-react-native-loopgcpayz-block-sdkgenerate-github-directorygenerator-openapi-repogerimismalamseninghseekgit-issuesgit-observergit-origin-checkgit-service-nodegit-sourcegit-url-promisegit-yoinkgitbook-start-iaas-bbdd-alex-moigitbook-start-iaas-ull-es-merquililyconygitbook-start-plugin-iaas-ull-es-noejaco2017gitcgithub-action-readmegithub-publish-npmgitlab-ci-variables-cligtniharry-reporterhzero-block-sdkjrennsoh88-react-native-scroll-indicatorjsnixkef-corekhaled-salem-custom-componentskonfig-release-itkonitorkuqoi-gitl-other-datalaboriouslambda-servicelcov-serverlernalicense-analysislime-climanage-dependencymangudinlagirajinmdnext-loadermf-cta-testingmiguelcostero-ng2-toastynative-apple-loginnative-kakao-loginnextra-theme-docs-mdxcomponentsng-apollonpm_one_1_2_3npm_qwertyoctokit-downloaderomgopen-pull-requestpackage-health-checkerpackage-json-from-gitpatchanon-clipatepangdeuipbcpileuleuyanteapr-changelog-genprep-barv11project-wajs-dvpublish-versionpupils-generate-newpyreswap-sdkqts-fissionquick-releasequinntainerrdmobilereablocks-docs-themereact-native-android-native-viewreact-native-android-video-player-viewreact-native-animate-textreact-native-arunjeyam1987react-native-arunmeena1987react-native-awesome-module-tworeact-native-azure-communication-servicesreact-native-basic-appreact-native-basic-screenreact-native-biometric-authenticatereact-native-bleccs-componentsreact-native-bubble-chartreact-native-build-vesion-getterreact-native-check-componentreact-native-components-designreact-native-contact-listreact-native-cplusreact-native-create-video-thumbnailreact-native-custom-poccomponentreact-native-datacapture-corereact-native-dhp-printerreact-native-fedlight-dsmreact-native-ghn-ekycreact-native-innity-remasterreact-native-input-libraryreact-native-is7react-native-kakao-mapsreact-native-klarify-iosreact-native-klcreact-native-library-testing-422522react-native-login-demo-testreact-native-manh-testreact-native-module-for-testingreact-native-multiplier-componentreact-native-multiplier-demoreact-native-multiplier2react-native-multiselectorreact-native-my-first-try-arun-ramyareact-native-nice-learningreact-native-paynow-generatorreact-native-payu-payment-testingreact-native-progress-arrowreact-native-rabbitmq-allreact-native-reanimated-sortable-listreact-native-rom-componentsreact-native-s-airlinesreact-native-sandycomponentreact-native-savczuk-feature-libraryreact-native-shared-gesturereact-native-test-comlibraryreact-native-ticker-tapereact-native-tone-testreact-native-uvc-camera-androidreact-native-withframework-checkreact-native-ytximkitredhatinsights-plugin-scaffolder-backendrefinejs-reporelease-itrelease-it-httpremax-statsrenovaterenovate-csmrepomrepomixrn-adyen-dropinrn-check-btnrn_unique_device_idscaffolder-coresedanbosoksemantic-release-github-milestonessemantic-release-gitmojisemantic-release-squash3sherry-utilssimple-github-releasesnipxspkstrapi-generate-newstylelint-formatter-utilssync-repostanyaotegittehmusimhujantemplate-typescript-node-packagetest-library-123testarmada-midwaytldwtodo2issuetooling-personaltoxics-rpcumi-build-devvision-camera-plugin-face-detectorvuepress-plugin-remote-urlwibywinx-form-winxworkspace-toolswsj.gatsby-source-gitzephyr-agent
:scroll: License
8 months ago
11 months ago
1 year ago
1 year ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
