github-url-from-username-repo
Advanced tools
Comparing version 0.0.2 to 0.1.0
module.exports = getUrl | ||
function getUrl (r) { | ||
if (!r) return | ||
if (/^[\w-]+\/[\w-]+$/.test(r)) | ||
if (!r) return null | ||
if (/^[\w-]+\/[\w\.-]+$/.test(r)) | ||
return "git://github.com/" + r | ||
else | ||
return null | ||
} | ||
} |
{ | ||
"name": "github-url-from-username-repo", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Create urls from username/repo", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,6 +9,3 @@ var assert = require("assert") | ||
}) | ||
it("works with -", function () { | ||
var url = getUrl("vision-media/express-package") | ||
assert.equal("git://github.com/vision-media/express-package", url) | ||
}) | ||
it("returns null if it does not match", function () { | ||
@@ -18,6 +15,22 @@ var url = getUrl("package") | ||
}) | ||
it("returns undefined if no repo/user was given", function () { | ||
it("returns null if no repo/user was given", function () { | ||
var url = getUrl() | ||
assert.deepEqual(undefined, url) | ||
assert.deepEqual(null, url) | ||
}) | ||
}) | ||
it("works with .", function () { | ||
var url = getUrl("component/downloader.js") | ||
assert.equal("git://github.com/component/downloader.js", url) | ||
}) | ||
it("works with . in the beginning", function () { | ||
var url = getUrl("component/.downloader.js") | ||
assert.equal("git://github.com/component/.downloader.js", url) | ||
}) | ||
it("works with -", function () { | ||
var url = getUrl("component/-dow-nloader.j-s") | ||
assert.equal("git://github.com/component/-dow-nloader.j-s", url) | ||
}) | ||
}) |
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
3770
36