Socket
Socket
Sign inDemoInstall

github-url-to-object

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-url-to-object - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

27

index.js

@@ -20,2 +20,3 @@ 'use strict'

obj.branch = shorthand[3] || 'master'
obj.host = 'github.com'
} else if (mediumhand) {

@@ -25,2 +26,3 @@ obj.user = mediumhand[1]

obj.branch = mediumhand[3] || 'master'
obj.host = 'github.com'
} else if (antiquated) {

@@ -30,2 +32,3 @@ obj.user = antiquated[1]

obj.branch = 'master'
obj.host = 'github.com'
} else {

@@ -39,3 +42,3 @@ // Turn git+http URLs into http URLs

if (!parsedURL.hostname) return null
if (parsedURL.hostname !== 'github.com') return null
var parts = parsedURL.pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\w-_\.\/]+)?/)

@@ -47,2 +50,4 @@ // ([\w-_\.]+)

obj.host = parsedURL.hostname || 'github.com'
if (parts[3]) {

@@ -57,18 +62,24 @@ obj.branch = parts[3].replace(/^\/tree\//, '').match(/[\w-_.]+\/{0,1}[\w-_]+/)[0]

obj.tarball_url = util.format('https://api.github.com/repos/%s/%s/tarball/%s', obj.user, obj.repo, obj.branch)
obj.clone_url = util.format('https://github.com/%s/%s', obj.user, obj.repo)
if (obj.host === 'github.com') {
obj.apiHost = 'api.github.com'
} else {
obj.apiHost = util.format('%s/api/v3', obj.host)
}
obj.tarball_url = util.format('https://%s/repos/%s/%s/tarball/%s', obj.apiHost, obj.user, obj.repo, obj.branch)
obj.clone_url = util.format('https://%s/%s/%s', obj.host, obj.user, obj.repo)
if (obj.branch === 'master') {
obj.https_url = util.format('https://github.com/%s/%s', obj.user, obj.repo)
obj.https_url = util.format('https://%s/%s/%s', obj.host, obj.user, obj.repo)
obj.travis_url = util.format('https://travis-ci.org/%s/%s', obj.user, obj.repo)
obj.zip_url = util.format('https://github.com/%s/%s/archive/master.zip', obj.user, obj.repo)
obj.zip_url = util.format('https://%s/%s/%s/archive/master.zip', obj.host, obj.user, obj.repo)
} else {
obj.https_url = util.format('https://github.com/%s/%s/blob/%s', obj.user, obj.repo, obj.branch)
obj.https_url = util.format('https://%s/%s/%s/blob/%s', obj.host, obj.user, obj.repo, obj.branch)
obj.travis_url = util.format('https://travis-ci.org/%s/%s?branch=%s', obj.user, obj.repo, obj.branch)
obj.zip_url = util.format('https://github.com/%s/%s/archive/%s.zip', obj.user, obj.repo, obj.branch)
obj.zip_url = util.format('https://%s/%s/%s/archive/%s.zip', obj.host, obj.user, obj.repo, obj.branch)
}
obj.api_url = util.format('https://api.github.com/repos/%s/%s', obj.user, obj.repo)
obj.api_url = util.format('https://%s/repos/%s/%s', obj.apiHost, obj.user, obj.repo)
return obj
}
{
"name": "github-url-to-object",
"version": "2.1.0",
"version": "2.2.0",
"description": "Extract user, repo, and other interesting properties from GitHub URLs",

@@ -8,5 +8,6 @@ "main": "index.js",

"test": "standard --format index.js && mocha",
"build": "browserify index.js --standalone gh > dist/gh.js"
"build": "browserify index.js --standalone gh > dist/gh.js",
"deploy": "npm run build && git subtree push --prefix dist origin gh-pages && open https://zeke.github.io/github-url-to-object"
},
"website": "https://github-url-to-object.herokuapp.com",
"website": "https://zeke.github.io/github-url-to-object",
"repository": {

@@ -31,2 +32,3 @@ "type": "git",

"browserify": "^4.2.1",
"harp": "^0.19.0",
"mocha": "^1.19.0",

@@ -33,0 +35,0 @@ "standard": "^3.7.0",

@@ -8,3 +8,3 @@ # github-url-to-object [![Build Status](https://travis-ci.org/zeke/github-url-to-object.png?branch=master)](https://travis-ci.org/zeke/github-url-to-object)

Check out the demo at https://github-url-to-object.herokuapp.com.
Check out the demo at [zeke.github.io/github-url-to-object](https://zeke.github.io/github-url-to-object).

@@ -27,3 +27,3 @@ ## Installation

Pass whatever flavor of github URL you like:
Use whatever flavor of GitHub URL you like:

@@ -76,3 +76,3 @@ ```js

If you provide a non-github URL or a falsy value, you'll get `null`.
If you provide a non-GitHub URL or a falsey value, you'll get `null`.

@@ -79,0 +79,0 @@ ## Test

@@ -30,5 +30,5 @@ /* globals before, describe, it */

describe('mediumhand', function () {
it('supports github:user/repo style', function () {
var obj = gh('user/repo#branch')
describe("mediumhand", function(){
it("supports github:user/repo style", function(){
var obj = gh("github:user/repo#branch")
assert.equal(obj.user, 'user')

@@ -38,4 +38,4 @@ assert.equal(obj.repo, 'repo')

it('supports github:user/repo#branch style', function () {
var obj = gh('user/repo#branch')
it("supports github:user/repo#branch style", function(){
var obj = gh("github:user/repo#branch")
assert.equal(obj.user, 'user')

@@ -89,2 +89,16 @@ assert.equal(obj.repo, 'repo')

describe('github enterprise', function() {
it("supports git@ URLs", function() {
var obj = gh("git@ghe.example.com:heroku/heroku-flags.git")
assert.equal(obj.user, 'heroku')
assert.equal(obj.repo, 'heroku-flags')
})
it("supports git:// URLs", function() {
var obj = gh("git://ghe.example.com/foo/bar.git")
assert.equal(obj.user, 'foo')
assert.equal(obj.repo, 'bar')
})
});
})

@@ -142,2 +156,15 @@

describe('github enterprise', function() {
it("supports http URLs", function() {
var obj = gh("http://ghe.example.com/zeke/outlet.git")
assert.equal(obj.user, 'zeke')
assert.equal(obj.repo, 'outlet')
})
it("supports https URLs", function() {
var obj = gh("https://ghe.example.com/zeke/outlet.git")
assert.equal(obj.user, 'zeke')
assert.equal(obj.repo, 'outlet')
})
});
})

@@ -148,38 +175,73 @@

before(function () {
obj = gh('zeke/ord')
})
describe('github.com', function() {
before(function(){
obj = gh("zeke/ord")
})
it('user', function () {
assert.equal(obj.user, 'zeke')
})
it("user", function() {
assert.equal(obj.user, "zeke")
})
it('repo', function () {
assert.equal(obj.repo, 'ord')
})
it("repo", function() {
assert.equal(obj.repo, "ord")
})
it('branch', function () {
assert.equal(obj.branch, 'master')
})
it("branch", function() {
assert.equal(obj.branch, "master")
})
it('tarball_url', function () {
assert.equal(obj.tarball_url, 'https://api.github.com/repos/zeke/ord/tarball/master')
})
it("tarball_url", function() {
assert.equal(obj.tarball_url, "https://api.github.com/repos/zeke/ord/tarball/master")
})
it('api_url', function () {
assert.equal(obj.api_url, 'https://api.github.com/repos/zeke/ord')
})
it("api_url", function() {
assert.equal(obj.api_url, "https://api.github.com/repos/zeke/ord")
})
it('https_url', function () {
assert.equal(obj.https_url, 'https://github.com/zeke/ord')
})
it("https_url", function() {
assert.equal(obj.https_url, "https://github.com/zeke/ord")
})
it('travis_url', function () {
assert.equal(obj.travis_url, 'https://travis-ci.org/zeke/ord')
it("travis_url", function() {
assert.equal(obj.travis_url, "https://travis-ci.org/zeke/ord")
})
it('zip_url', function () {
assert.equal(obj.zip_url, 'https://github.com/zeke/ord/archive/master.zip')
})
})
it('zip_url', function () {
assert.equal(obj.zip_url, 'https://github.com/zeke/ord/archive/master.zip')
describe('github enterprise', function() {
before(function(){
obj = gh("https://ghe.example.com/zeke/outlet.git")
})
it("user", function() {
assert.equal(obj.user, "zeke")
})
it("repo", function() {
assert.equal(obj.repo, "outlet")
})
it("branch", function() {
assert.equal(obj.branch, "master")
})
it("tarball_url", function() {
assert.equal(obj.tarball_url, "https://ghe.example.com/api/v3/repos/zeke/outlet/tarball/master")
})
it("api_url", function() {
assert.equal(obj.api_url, "https://ghe.example.com/api/v3/repos/zeke/outlet")
})
it("https_url", function() {
assert.equal(obj.https_url, "https://ghe.example.com/zeke/outlet")
})
it('zip_url', function () {
assert.equal(obj.zip_url, 'https://ghe.example.com/zeke/outlet/archive/master.zip')
})
})
})

@@ -227,10 +289,4 @@

})
it('returns null for non-github URLs', function () {
var obj = gh('https://bitbucket.com/other/thing')
assert.equal(obj, null)
})
})
})

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc