1.2.0 • Published 7 months ago

parse-git-url v1.2.0

Weekly downloads
4,767
License
MIT
Repository
github
Last release
7 months ago

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