A high level git url parser for common git providers.
# Using npm
npm install --save git-url-parse
# Using yarn
yarn add git-url-parse// Dependencies
const GitUrlParse = require("git-url-parse");
console.log(GitUrlParse("[email protected]:IonicaBizau/node-git-url-parse.git"));
// => {
// protocols: []
// , port: null
// , resource: "github.com"
// , user: "git"
// , pathname: "/IonicaBizau/node-git-url-parse.git"
// , hash: ""
// , search: ""
// , href: "[email protected]: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"));
// => "[email protected]:IonicaBizau/node-git-url-parse.git"
console.log(GitUrlParse("[email protected]:IonicaBizau/node-git-url-parse.git").toString("https"));
// => "https://github.com/IonicaBizau/node-git-url-parse.git"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. π
- For direct and quick help, you can use Codementor. π
Parses a Git url.
- String
url: The Git url to parse.
- 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.
Stringifies a GitUrl object.
- GitUrl
obj: The parsed Git url object. - String
type: The type of the stringified url (defaultobj.protocol).
- String The stringified url.
Have an idea? Found a bug? See how to contribute.
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 π
-
βI love books! I will remember you after years if you buy me one. π π
-
βYou can make one-time donations via PayPal. I'll probably buy a
coffeetea. π΅ -
β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! β€οΈ
If you are using this library in one of your projects, add it in this list. β¨
release-itdocumentationapollo@atomist/automation-client@storybook/storybook-deployer@backstage/plugin-catalog@kadira/storybook-deployer@backstage/backend-commongatsby-source-gitumi-build-devapify-shared@atomist/automation-client-ext-ravengit-source@qiwi/semantic-release-gh-pages-plugin@atomist/sdm-pack-analysis@git-stack/server-core@nuxt/telemetry@lerna/github-client@umijs/block-sdk@instructure/ui-scriptslambda-service@wetrial/block-sdkhzero-block-sdk@micro-app/shared-utilsremax-statsscaffolder-coreworkspace-tools@log4brains/coresemantic-release-gitmoji@feizheng/next-git-urlbeachball@xdn/cligitbook-start-plugin-iaas-ull-es-noejaco2017autorelease-setupdocumentation-custom-markdown@hygiene/plugin-github-urlsherry-utils@unibtc/release-itclipped@erquhart/lerna-github-client@0x-lerna-fork/github-clientcommon-boilerplate@brisk-docs/website@hawkingnetwork/react-native-tab-viewmiguelcostero-ng2-toastydocula-ui@brisk-docs/gatsby-generator@microservices/clistylelint-formatter-utilsomg@facadecompany/ignition-ui@geut/git-url-parse@temporg/rds-scripts@koumoul/gh-pages-multisync-repos@yarnpkg/plugin-git@atomist/uhura@atomist/cli@git-stack/hemera-plugin@s-ui/mono@atomist/skill@backstage/plugin-catalog-backend@backstage/integrationcommittinggitbook-start-https-alex-moigitbook-start-iaas-ull-es-merquililyconyproyecto-sytw-alex-moigitbook-start-iaas-ull-es-alex-moigitbook-start-iaas-bbdd-alex-moicomplan@axetroy/git-clonegenerator-cleanphp@axetroy/gpmxgenerator-ckeditor4documentation-habitlabnodeschool-adminone-more-gitlab-clidef-coregd-clinode-coverage-serverstrappergithub-publish-npmoghsinitsmart-clonedownload-repo-cligenerator-nm-btigitcgitlinegitlab-ci-variables-cligitlab-ci-variables-setter-clidocumentation-fork@axetroy/gpmgenerator-openapi-repogit-url-promisekef-core@pvdlg/semantic-releasegitlab-tool-clisnipxyarn-upgrade-on-ci@hjin/generator-app@reframe/github-pagesbelt-repo@esops/publish-github-pages@hugomrdias/documentationjust-dev-sdk@activeviam/documentationgit-signedcz-conventional-changelog-befe@voodeng/archive@voodeng/uppackscreate-apex-js-appauto-changelog-vstsharry-reporter@campus-online/gatsby-source-gitgtnici-yarn-upgradegenerator-clearphpopenapi-repo-generatorgit-imitatevscode-gpmdocumentation42@limejs/clilime-clilaboriousrelease-it-httpbibilcov-servercreate-release-itgit-service-node@infinitecsolutions/storybook-deployer@1nd/documentationgit-cherry-fixvuepress-plugin-remote-urlgatsby-source-github-rawmoto-connector@zpmpkg/zpmkonitorrelease2hub@geut/git-compare-template@geut/chan-parsergit-observerdocula-ui-expresssn-flutter-bootspkumi-plugin-repo@epranka/create-tsx-packageflutter-bootnode-normanremote-commit-urlair-material_cli@belt/repo@arcanis/sherlock@dandean/storybook-deployergit-upstream@cratosw/gatsby-antd@tjmonsi/generator-uplb-hci-lab-project-template@tagoro9/gittldwgatsby-theme-hansinaral-vps-testgenerate-preview@temporg/ui-scriptsbitbucket-pullr@whey/gatsby-theme-whey@docomodigital/pdorauto-clonecreate-sourcegraph-extensioncreate-naral-servergatsby-source-git-remotes@vicoders/cli2@amorist/gatsby-theme-antd@stavalfi/cicirodown@apardellass/react-native-audio-streamgatsby-theme-conechangelog.mdwp-continuous-deploymentl2forlerna@patrickhulce/scripts@cilyn/bitbucketreact-native-plugpag-wrappermeta-releasegit-csvship-releasessh-remote@senti-techlabs/generator-senti-project-templatefotingoreact-native-pulsator-native@epranka/create-packagegit-lab-cli@csmith/release-itquery-registrycetus-cli@gasket/plugin-metricsreact-native-kakao-mapsgenerate-github-directory@rescribe/cliconfigorama@geeky-apo/react-native-advanced-clipboardnative-apple-loginnative-google-login@tahini/nc@shopgate/pwa-releasernative-kakao-login@hemith/react-native-tnk@cyber-tools/cyber-npm@pagedip/tool-autoreleasekit-commanddetect-node-support@tcorley/storybook-addon-material-uimira@elestu/actions-dependacopreact-native-contact-list@s-ui/changelogbranch-release@myetherwallet/mew-components@corelmax/react-native-my2c2p-sdkwsj.gatsby-source-gitgit-push-prsinanews-flutter-boot@pubcore/node-docker-build@hnp/package-scriptskaskadi-cli@s-ui/cicc-flowgit-origin-check@datalogic/react-native-datalogic-module@reshiftsecurity/reshift-plugin-npm@dvcorg/cmllage@cloudoki/donderflowgit-multi-profile@antv/gatsby-theme-antvgatsby-source-npmjs@atomist/ci-sdmdocumentation-markdown-themes@git-stack/module-server@alitajs/block-sdk@jswork/topics2keywordsactions-package-update@backstage/plugin-scaffolder-backend@backstage/plugin-catalog-import@bcgov/gatsby-source-github-raw@theowenyoung/gatsby-source-git@s-ui/ssrgithub-action-readmecanaristdx-scanner@vamsikc/plugin-catalog@backstage/techdocs-common@backstage/plugin-techdocs-backendpr-loggit-issues


