You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

bitbucket-url-to-object

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitbucket-url-to-object

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

0.3.0
latest
Source
npmnpm
Version published
Weekly downloads
4.2K
18.45%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

bitbucket

FAQs

Package last updated on 26 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts