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 4.0.0 to 4.0.1

15

dist/commonjs.js
'use strict'
var url = require('url')
var isUrl = require('is-url')
var laxUrlRegex = /(?:(?:[a-z]+:)?[/][/])?([^/]+)([/][^?#]+)/
module.exports = function (repoUrl, opts) {

@@ -42,8 +43,10 @@ var obj = {}

if (!isUrl(repoUrl)) { return null }
var parsedURL = url.parse(repoUrl)
if (!parsedURL.hostname) { return null }
if (parsedURL.hostname !== 'github.com' && parsedURL.hostname !== 'www.github.com' && !opts.enterprise) { return null }
var ref = repoUrl.match(laxUrlRegex) || [];
var hostname = ref[1];
var pathname = ref[2];
if (!hostname) { return null }
if (hostname !== 'github.com' && hostname !== 'www.github.com' && !opts.enterprise) { return null }
var parts = parsedURL.pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\w-_\.\/]+)?/)
var parts = pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\w-_\.\/]+)?/)
// ([\w-_\.]+)

@@ -54,3 +57,3 @@ if (!parts) { return null }

obj.host = parsedURL.hostname || 'github.com'
obj.host = hostname || 'github.com'

@@ -57,0 +60,0 @@ if (parts[3] && /^\/tree\/master\//.test(parts[3])) {

22

dist/gh.js
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.gh = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a){ return a(o,!0); }if(i){ return i(o,!0); }var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++){ s(r[o]); }return s})({1:[function(require,module,exports){
'use strict'
var url = require('url')
var isUrl = require('is-url')
var laxUrlRegex = /(?:(?:[a-z]+:)?[/][/])?([^/]+)([/][^?#]+)/
module.exports = function (repoUrl, opts) {

@@ -43,8 +44,10 @@ var obj = {}

if (!isUrl(repoUrl)) { return null }
var parsedURL = url.parse(repoUrl)
if (!parsedURL.hostname) { return null }
if (parsedURL.hostname !== 'github.com' && parsedURL.hostname !== 'www.github.com' && !opts.enterprise) { return null }
var ref = repoUrl.match(laxUrlRegex) || [];
var hostname = ref[1];
var pathname = ref[2];
if (!hostname) { return null }
if (hostname !== 'github.com' && hostname !== 'www.github.com' && !opts.enterprise) { return null }
var parts = parsedURL.pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\w-_\.\/]+)?/)
var parts = pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\w-_\.\/]+)?/)
// ([\w-_\.]+)

@@ -55,3 +58,3 @@ if (!parts) { return null }

obj.host = parsedURL.hostname || 'github.com'
obj.host = hostname || 'github.com'

@@ -99,3 +102,3 @@ if (parts[3] && /^\/tree\/master\//.test(parts[3])) {

},{"is-url":2,"url":3}],2:[function(require,module,exports){
},{"is-url":2}],2:[function(require,module,exports){

@@ -125,8 +128,3 @@ /**

},{}],3:[function(require,module,exports){
module.exports.parse = function (string) {
return new window.URL(string)
}
},{}]},{},[1])(1)
});
'use strict'
var url = require('url')
var isUrl = require('is-url')
var laxUrlRegex = /(?:(?:[a-z]+:)?[/][/])?([^/]+)([/][^?#]+)/
module.exports = function (repoUrl, opts) {

@@ -42,8 +43,8 @@ var obj = {}

if (!isUrl(repoUrl)) return null
var parsedURL = url.parse(repoUrl)
if (!parsedURL.hostname) return null
if (parsedURL.hostname !== 'github.com' && parsedURL.hostname !== 'www.github.com' && !opts.enterprise) return null
const [, hostname, pathname] = repoUrl.match(laxUrlRegex) || []
if (!hostname) return null
if (hostname !== 'github.com' && hostname !== 'www.github.com' && !opts.enterprise) return null
var parts = parsedURL.pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\w-_\.\/]+)?/)
var parts = pathname.match(/^\/([\w-_]+)\/([\w-_\.]+)(\/tree\/[\w-_\.\/]+)?(\/blob\/[\w-_\.\/]+)?/)
// ([\w-_\.]+)

@@ -54,3 +55,3 @@ if (!parts) return null

obj.host = parsedURL.hostname || 'github.com'
obj.host = hostname || 'github.com'

@@ -57,0 +58,0 @@ if (parts[3] && /^\/tree\/master\//.test(parts[3])) {

{
"name": "github-url-to-object",
"version": "4.0.0",
"version": "4.0.1",
"description": "Extract user, repo, and other interesting properties from GitHub URLs",

@@ -26,5 +26,2 @@ "main": "dist/commonjs.js",

},
"browser": {
"url": "./url-browser"
},
"dependencies": {

@@ -31,0 +28,0 @@ "is-url": "^1.1.0"

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