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

/parse-git-url/

    Package Sidebar

    Install

    npm i parse-git-url

    Weekly Downloads

    180,351

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    7.33 kB

    Total Files

    7

    Last publish

    Collaborators

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