Socket
Socket
Sign inDemoInstall

github-url-from-git

Package Overview
Dependencies
11
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

History.md

9

index.js

@@ -0,8 +1,9 @@

var re = /^(?:https?:\/\/|git:\/\/)?(?:[^@]+@)?(gist.github.com|github.com)[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/
module.exports = function(url){
try {
var m = /^.*?github\.com[:\/]([^\/]+)\/([^\/.]+)(?:\.git)?/.exec(url);
var user = m[1];
var repo = m[2];
return 'https://github.com/' + user + '/' + repo;
var m = re.exec(url.replace(/\.git$/, ''));
var host = m[1];
var path = m[2];
return 'https://' + host + '/' + path;
} catch (err) {

@@ -9,0 +10,0 @@ // ignore

{
"name": "github-url-from-git",
"version": "1.0.0",
"version": "1.1.0",
"description": "Parse a github git url and return the github repo url",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha test.js --reporter spec --require should"
},

@@ -9,0 +9,0 @@ "repository": "",

@@ -25,3 +25,18 @@

})
});
it('should return undefined on failure', function(){
var url = 'git://github.com/justgord/.git';
assert(null == parse(url));
})
it('should parse git@gist urls', function() {
var url = 'git@gist.github.com:3135914.git';
parse(url).should.equal('https://gist.github.com/3135914')
})
it('should parse https://gist urls', function() {
var url = 'https://gist.github.com/3135914.git';
parse(url).should.equal('https://gist.github.com/3135914')
})
})
```

@@ -30,2 +30,12 @@

})
it('should parse git@gist urls', function() {
var url = 'git@gist.github.com:3135914.git';
parse(url).should.equal('https://gist.github.com/3135914')
})
it('should parse https://gist urls', function() {
var url = 'https://gist.github.com/3135914.git';
parse(url).should.equal('https://gist.github.com/3135914')
})
})
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc