parse-git-url
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

parse-git-url

A lib for parsing the URL of GitHub, GitHub Enterprise Server (ghes), GitLab, and Bitbucket repositories.

Usage

import parseGitUrl from 'parse-git-url'

parseGitUrl('https://github.com/vercel/swr'))
// => {
//   type: 'github',
//   owner: 'vercel',
//   name: 'swr',
//   branch: '',
//   sha: '',
//   subdir: ''
// }

parseGitUrl('https://github.example.com/vercel/swr', 'github.example.com'))
// => {
//   type: 'ghes',
//   owner: 'vercel',
//   name: 'swr',
//   branch: '',
//   sha: '',
//   subdir: ''
// }

parseGitUrl('https://google.com')
// => null

It supports parsing various URL schemas including SSH, branch, sha, commit, subdirectories, subgroups (GitLab), etc.

Author

Shu Ding (@shuding_) – Vercel

Readme

Keywords

none

Package Sidebar

Install

npm i parse-git-url

Weekly Downloads

63,248

Version

1.2.0

License

MIT

Unpacked Size

7.33 kB

Total Files

7

Last publish

Collaborators

  • gdborton
  • matheuss
  • quietshu
  • matt.straka
  • nick.tracey
  • zeit-bot
  • vercel-release-bot