|
|
3 years ago | |
|---|---|---|
| .. | ||
| lib | 3 years ago | |
| LICENSE | 3 years ago | |
| README.md | 3 years ago | |
| package.json | 3 years ago | |

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("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"
There are few ways to get help:
gitUrlParse(url)Parses a Git url.
url: The Git url to parse.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.
obj: The parsed Git url object.type: The type of the stringified url (default obj.protocol).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:
Bitcoin—You can send me bitcoins at this address (or scanning the code below): 1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6
Thanks! :heart:
If you are using this library in one of your projects, add it in this list. :sparkles:
release-itdocumentationapollo@atomist/automation-client@storybook/storybook-deployer@backstage/backend-common@backstage/integration@kadira/storybook-deployergatsby-source-gitumi-build-dev@era-ci/utils@atomist/automation-client-ext-ravenworkspace-toolsapify-sharedstrapi-generate-new@nuxt/telemetrysemantic-release-gitmojigit-source@qiwi/semantic-release-gh-pages-plugin@git-stack/server-core@atomist/sdm-pack-analysis@lerna/github-clientcommon-boilerplate@backstage/plugin-catalogrenovate@umijs/block-sdk@appirio/appirio@s-ui/studio@instructure/ui-scripts@wetrial/block-sdkhzero-block-sdkremax-stats@feizheng/next-git-url@radjs/block-sdk@log4brains/corescaffolder-core@xdn/cliquery-registry@appworks/project-utilsbeachball@oumi/block-sdk@zeplin/cli@backstage/techdocs-common@atomist/skill@backstage/plugin-scaffolder-backend@backstage/plugin-catalog-backend@micro-app/shared-utilsgitbook-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-clientdocula-ui@brisk-docs/gatsby-generator@microservices/clistylelint-formatter-utilsomg@facadecompany/ignition-ui@temporg/rds-scripts@git-stack/hemera-plugin@vamsikc/plugin-catalog@pubbo/github-client@jaredpalmer/workspace-tools@iceworks/project-utilssync-repos@sanv/apify-shared@atomist/cli@atomist/uhuralambda-service@s-ui/monofotingo@yarnpkg/plugin-gitwibygenerator-clearphp@oumi/cli-ui@koumoul/gh-pages-multi@pmworks/project-utils@geut/git-url-parse@strapi/generate-new@backstage/plugin-techdocs@backstage/plugin-scaffoldercommittinggitbook-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-vsts@campus-online/gatsby-source-gitgtnici-yarn-upgradeopenapi-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@dandean/storybook-deployergit-upstream@cratosw/gatsby-antd@tjmonsi/generator-uplb-hci-lab-project-templategatsby-theme-hansingenerate-preview@temporg/ui-scriptsbitbucket-pullr@whey/gatsby-theme-whey@docomodigital/pdorauto-clonearal-servergatsby-source-git-remotes@amorist/gatsby-theme-antd@stavalfi/ci@apardellass/react-native-audio-streamgatsby-theme-conechangelog.mdwp-continuous-deploymentl2forlerna@cilyn/bitbucketreact-native-plugpag-wrappermeta-releasegit-csvship-releasessh-remotereact-native-pulsator-native@epranka/create-package@csmith/release-itcetus-clireact-native-kakao-mapsconfigorama@geeky-apo/react-native-advanced-clipboardnative-apple-loginnative-google-login@tahini/nc@hemith/react-native-tnk@pagedip/tool-autoreleasereact-native-contact-listbranch-release@corelmax/react-native-my2c2p-sdkwsj.gatsby-source-git@pubcore/node-docker-buildcc-flowgit-origin-checkgatsby-source-npmjs@git-stack/module-server@jswork/topics2keywordsactions-package-updategithub-action-readme@rescribe/clireact-native-responsive-size@gvhinks/wibymdnext-loadernext-mdx-booksmdxbookftl-renovate@emedvedev/renovatecreate-sourcegraph-extension@hnp/package-scriptsreact-native-test-module-hhhgit-multi-profilereact-native-is7@s-ui/changeloggenerate-github-directorycreate-n@wpbrothers/sbcli@turborepo/workspace-toolslearning-journal-ci@arcanis/sherlock@carrotwu/wcli@zalando-backstage/plugin-catalogmiragithub-assistant@vicoders/cli2patchanon-cligatsby-theme-zh@gasket/plugin-metricsmyrenobatebotmyrenovatebot@buganto/client@patrickhulce/scriptsgatsby-theme-nestxkit-command@datalogic/react-native-datalogic-module@pipelinedoc/cli@atomist/ci-sdm@cyber-tools/cyber-npmcanaristpbc@1coin178/github-compare@elestu/actions-dependacop@senti-techlabs/generator-senti-project-template@lerna-test-v1/gitgit-lab-clibirken-react-native-community-image-editorsinanews-flutter-bootdetect-node-supportnmrium-clifster@tagoro9/gitnative-kakao-logingithub-booksblog-flutter-boot@bcgov/gatsby-source-github-raw@rianfowler/backstage-backend-commonreact-native-modal-progress-bar@lerna-test-v1/markdowndx-scannerharry-reportertldwreact-native-dsphoto-module@brisk-docs/website@hawkingnetwork/react-native-tab-viewmiguelcostero-ng2-toastyaral-vps-test@wolfe-labs/du-luacdrowl-base-theme-iconset@shopgate/pwa-releaserrn-custom-tabview@theowenyoung/gatsby-source-git@apify/gitgit-yoink@makepad/puppeteer-cli@flareapp/ignition-uijsnix@rocket.chat/houston@generates/kdot@felipesimmi/react-native-datalogic-moduletooling-personalpublish-version@dvcorg/cmlcirodownsemantic-release-telegrambridgewwater-cligit-push-pr@reshiftsecurity/reshift-plugin-npmtemp-gatsby-theme@evanpurkhiser/tooling-personal@cythral/renovate@domestika/monovuepress-theme-nextdocumentation-markdown-themes@s-ui/ssr@alitajs/block-sdkcoc-discord-rpc@dougkulak/semantic-release-gh-pages-plugin@guardian/cdkreact-native-flyy@oat-sa/tao-extension-release@antv/gatsby-theme-antv@stackbit/cli@myetherwallet/mew-componentsrocali-apollocopy-github-directory@githubtraining/github-exercise-managercreate-strapi-starter@backstage/plugin-catalog-importlage@layer0/clipr-loggit-issues