JSPM

bitbucket-url-to-object

0.3.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4030
  • Score
    100M100P100Q129493F
  • License MIT

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

Package Exports

  • bitbucket-url-to-object

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bitbucket-url-to-object) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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