parse-git-url
v1.2.0
Published
A lib for parsing the URL of Git Repositories.
Downloads
1,434,487
Keywords
Readme
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.