# urlgithub-object

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

Latest version **1.0.2** (published 2024-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install urlgithub-object
pnpm add urlgithub-object
yarn add urlgithub-object
bun add urlgithub-object
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-03-03 |
| First published | 2024-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 29.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | leiz95 |
| Maintainers | leiz1995 |
| Keywords | github, url, repo |

## Links

- npm: https://www.npmjs.com/package/urlgithub-object
- Repository: https://github.com/leiz95/URLgithub-object
- Homepage: https://github.com/leiz95/URLgithub-object#readme
- Issues: https://github.com/leiz95/URLgithub-object/issues
- npm.io page: https://npm.io/package/urlgithub-object

## Dependencies (2)

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

## 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

- 1.0.2 (latest) — 2024-03-03
- 1.0.1 — 2024-03-03
- 1.0.0 — 2024-03-03

## README

# urlgithub-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-to-object](https://github.com/leiz95/URLBitbucket-to-object.git).


## Installation

For Node.js or Browserify usage:

```sh
npm i urlgithub-object
```

For bower usage:

```sh
bower install urlgithub-object
```

## Usage

Use whatever flavor of GitHub URL you like:

```js
const gh = require('urlgithub-object')

gh('github:example/business')
gh('https://github.com/example/business')
gh('https://github.com/example/business/tree/master')
gh('https://github.com/example/business/tree/master/nested/file.js')
gh('https://github.com/example/business.git')
gh('http://github.com/example/business')
gh('git://github.com/example/business.git')
gh('git+https://github.com/example/business.git')
```

Here's what you'll get:

```js
{
  user: 'example',
  repo: 'business',
  branch: 'master',
  tarball_url: 'https://api.github.com/repos/example/business/tarball/master',
  clone_url: 'https://github.com/example/business',
  https_url: 'https://github.com/example/business',
  travis_url: 'https://travis-ci.org/example/business',
  api_url: 'https://api.github.com/repos/example/business'
  zip_url: 'https://github.com/example/business/archive/master.zip'
}
```

The shorthand form lets you specify a branch:

```js
gh('github:example/business#nachos')
```

```js
{
  user: 'example',
  repo: 'business',
  branch: 'nachos',
  https_url: 'https://github.com/example/business/blob/nachos',
  tarball_url: 'https://api.github.com/repos/example/business/tarball/nachos',
  clone_url: 'https://github.com/example/business',
  travis_url: 'https://travis-ci.org/example/business?branch=nachos',
  api_url: 'https://api.github.com/repos/example/business'
  zip_url: 'https://github.com/example/business/archive/nachos.zip'
}
```

If you provide a non-GitHub URL or a falsey value, you'll get `null`.

## 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/urlgithub-object · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
