Skip to content

Parse a bitbucket git url and return the bitbucket repo url

License

Notifications You must be signed in to change notification settings

alex-e-leon/bitbucket-url-from-git

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitbucket-url-from-git

Blatantly ripped off tj/node-github-url-from-git But tweaked for bitbucket urls

describe('parse(url)', function () {
  it('should support git://*', function () {
    var url = '[email protected]:alex-e-leon/node-bitbucket-url-from-git.git'
    parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
  })

  it('should support git://*.git', function () {
    var url = 'git://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git'
    parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
  })

  it('should support https://*', function () {
    var url = 'https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git'
    parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
  })

  it('should support https://*.git', function () {
    var url = 'https://[email protected]/alex-e-leon/node-bitbucket-url-from-git.git'
    parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
  })

  it('should return undefined on failure', function () {
    var url = 'git://bitbucket.org/alex-e-leon/.git'
    assert(parse(url) == null)
  })

  it('should parse [email protected]:/alex-e-leon/node-bitbucket-url-from-git.git', function () {
    var url = '[email protected]:/alex-e-leon/node-bitbucket-url-from-git.git'
    parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
  })

  it('should parse [email protected]:bcoe/thumbd.git#2.7.0', function () {
    var url = '[email protected]:alex-e-leon/node-bitbucket-url-from-git.git#2.7.0'
    parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
  })

  it('should parse git+https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git', function () {
    var url = 'git+https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git'
    parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
  })

  it('should parse git+ssh://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git', function () {
    var url = 'git+ssh://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git'
    parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
  })

  // snippet urls.

  it('should parse git@ snippet urls', function () {
    var url = '[email protected]:snippets/alex-e-leon/nepk84/a-snippet.git'
    parse(url).should.equal('https://bitbucket.org/snippets/alex-e-leon/nepk84')
  })

  it('should parse https://gist urls', function () {
    var url = 'https://[email protected]/snippets/alex-e-leon/nepk84/a-snippet.git'
    parse(url).should.equal('https://bitbucket.org/snippets/alex-e-leon/nepk84')
  })

  // Handle arbitrary GitHub Enterprise domains.

  it('should parse parse extra bitbucket enterprise urls provided', function () {
    var url = 'git://bitbucket.example.com/alex-e-leon/node-bitbucket-url-from-git.git'
    parse(
      url, {extraBaseUrls: ['bitbucket.example.com']}
    ).should.equal('https://bitbucket.example.com/alex-e-leon/node-bitbucket-url-from-git')
  })

  it('should parse bitbucket enterprise urls with multiple subdomains', function () {
    var url = 'git://bitbucket.internal.example.com/alex-e-leon/node-bitbucket-url-from-git.git'
    parse(
      url, {extraBaseUrls: ['bitbucket.internal.example.com']}
    ).should.equal('https://bitbucket.internal.example.com/alex-e-leon/node-bitbucket-url-from-git')
  })
})

About

Parse a bitbucket git url and return the bitbucket repo url

Resources

License

Stars

Watchers

Forks

Packages

No packages published