Skip to content

A node module that extracts useful properties like user, repo, and branch from various flavors of Bitbucket URLs.

Notifications You must be signed in to change notification settings

zeke/bitbucket-url-to-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A node module that extracts useful properties like user, repo, and branch from various flavors of Bitbucket URLs.

Resources

Stars

Watchers

Forks

Packages

No packages published