github-url-to-object
Advanced tools
Comparing version 0.2.0 to 0.2.1
11
index.js
module.exports = function(url) { | ||
var parts = require("url") | ||
.parse(url) | ||
.path | ||
.replace(/\.git/, '') | ||
.replace(/^\//, '') | ||
.split('/') | ||
var re = /^(?:https?:\/\/|git:\/\/)?(?:[^@]+@)?(gist.github.com|github.com)[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/ | ||
var match = re.exec(url.replace(/\.git$/, '')); | ||
// support shorthand URLs | ||
var parts = match ? match[2].split('/') : url.split('/') | ||
return { | ||
@@ -11,0 +10,0 @@ user: parts[0], |
{ | ||
"name": "github-url-to-object", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Extract username and repo name from various flavors of GitHub URLs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -37,2 +37,8 @@ var mocha = require("mocha"); | ||
it("handles git@ URLs", function() { | ||
var obj = gh("git@github.com:heroku/heroku-flags.git"); | ||
assert.equal(obj.user, 'heroku'); | ||
assert.equal(obj.repo, 'heroku-flags'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2856
50