# github-url-to-object

> Extract user, repo, and other interesting properties from GitHub URLs

Latest version **4.0.6** (published 2021-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install github-url-to-object
pnpm add github-url-to-object
yarn add github-url-to-object
bun add github-url-to-object
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.6 |
| Published | 2021-04-21 |
| First published | 2013-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/github-url-to-object) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 29.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 89 |
| Author | zeke |
| Maintainers | zeke |
| Keywords | github, url, repo |

## Links

- npm: https://www.npmjs.com/package/github-url-to-object
- Repository: https://github.com/zeke/github-url-to-object
- Homepage: https://github.com/zeke/github-url-to-object#readme
- Issues: https://github.com/zeke/github-url-to-object/issues
- npm.io page: https://npm.io/package/github-url-to-object

## Dependencies (1)

- [is-url](https://npm.io/package/is-url.md) ^1.1.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 4.0.6 (latest) — 2021-04-21
- 4.0.5 — 2021-04-21
- 4.0.4 — 2018-02-26
- 4.0.2 — 2017-06-21
- 4.0.1 — 2017-06-20
- 4.0.0 — 2017-06-07
- 3.1.0 — 2017-03-15
- 3.0.0 — 2017-02-02
- 2.2.6 — 2016-10-31
- 2.2.5 — 2016-10-31
- 2.2.4 — 2016-09-04
- 2.2.3 — 2016-07-11
- 2.2.2 — 2016-07-11
- 2.2.1 — 2016-02-29
- 2.2.0 — 2016-02-29
- … 29 more at https://npm.io/package/github-url-to-object/versions

## README

# github-url-to-object  [![Build Status](https://travis-ci.org/zeke/github-url-to-object.png?branch=master)](https://travis-ci.org/zeke/github-url-to-object)

A module for node.js and browsers that extracts useful properties like `user`,
`repo`, and `branch` from various flavors of GitHub URLs.

There's also a Bitbucket equivalent to this library: [bitbucket-url-to-object](https://github.com/zeke/bitbucket-url-to-object).

Check out the demo at [zeke.github.io/github-url-to-object](https://zeke.github.io/github-url-to-object).

## Installation

For Node.js or Browserify usage:

```sh
npm i github-url-to-object
```

For bower usage:

```sh
bower install github-url-to-object
```

## Usage

Use whatever flavor of GitHub URL you like:

```js
const gh = require('github-url-to-object')

gh('github:monkey/business')
gh('https://github.com/monkey/business')
gh('https://github.com/monkey/business/tree/master')
gh('https://github.com/monkey/business/tree/master/nested/file.js')
gh('https://github.com/monkey/business.git')
gh('http://github.com/monkey/business')
gh('git://github.com/monkey/business.git')
gh('git+https://github.com/monkey/business.git')
```

Here's what you'll get:

```js
{
  user: 'monkey',
  repo: 'business',
  branch: 'master',
  tarball_url: 'https://api.github.com/repos/monkey/business/tarball/master',
  clone_url: 'https://github.com/monkey/business',
  https_url: 'https://github.com/monkey/business',
  travis_url: 'https://travis-ci.org/monkey/business',
  api_url: 'https://api.github.com/repos/monkey/business'
  zip_url: 'https://github.com/monkey/business/archive/master.zip'
}
```

The shorthand form lets you specify a branch:

```js
gh('github:monkey/business#nachos')
```

```js
{
  user: 'monkey',
  repo: 'business',
  branch: 'nachos',
  https_url: 'https://github.com/monkey/business/blob/nachos',
  tarball_url: 'https://api.github.com/repos/monkey/business/tarball/nachos',
  clone_url: 'https://github.com/monkey/business',
  travis_url: 'https://travis-ci.org/monkey/business?branch=nachos',
  api_url: 'https://api.github.com/repos/monkey/business'
  zip_url: 'https://github.com/monkey/business/archive/nachos.zip'
}
```

If you provide a non-GitHub URL or a falsey value, you'll get `null`.

### GitHub Enterprise

If you're using GitHub Enterprise, pass the `enterprise` option to allow
your non-`github.com` URL to be parsed:

```js
gh('https://ghe.example.com:heroku/heroku-flags.git', { enterprise: true })
```

## Test

```sh
npm install
npm test
```

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

## License

MIT

---
_Source: https://npm.io/package/github-url-to-object · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
