bitbucket-url-to-object

Extract user, repo, and other interesting properties from Bitbucket URLs

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
bitbucket-url-to-object
0.3.07 years ago8 years agoMinified + gzip package size for bitbucket-url-to-object in KB

Readme

bitbucket-url-to-object Build Status
A node module that extracts useful properties like user and repo from various flavors of bitbucket URLs.
There's also a GitHub equivalent to this library: github-url-to-object.

Installation

npm install bitbucket-url-to-object --save

Usage

Pass whatever flavor of bitbucket URL you like:
var bb = require('bitbucket-url-to-object')

bb('monkey/business')
bb('bitbucket:monkey/business')
bb('https://bitbucket.org/monkey/business')
bb('https://bitbucket.org/monkey/business.git')
bb('http://bitbucket.org/monkey/business')
bb('git://bitbucket.org/monkey/business.git')

Here's what you'll get:
{
  user: 'monkey',
  repo: 'business',
  branch: 'master',
  https_url: 'https://bitbucket.org/monkey/business',
  tarball_url: 'https://bitbucket.org/monkey/business/get/master.tar.gz'
  travis_url: 'https://travis-ci.org/monkey/business',
}

The shorthand format lets you specify a branch:
bb('monkey/business#nachos')
{
user: 'monkey',
repo: 'business',
branch: 'nachos',
https_url: 'https://bitbucket.org/monkey/business/tree/nachos',
tarball_url: 'https://bitbucket.org/monkey/business/get/nachos.tar.gz'
travis_url: 'https://travis-ci.org/monkey/business',
}

If you provide a non-bitbucket URL or a falsy value, you'll get null.

Test

npm install
npm test

License

MIT