Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github-url-from-username-repo

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-url-from-username-repo - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

6

index.js
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)
})
})
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