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 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');
});
});
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