github-username
Advanced tools
Comparing version
30
index.js
'use strict'; | ||
var request = require('request'); | ||
var got = require('got'); | ||
var querystring = require('querystring'); | ||
@@ -22,20 +23,23 @@ module.exports = function (email, token, cb) { | ||
request.get({ | ||
url: 'https://api.github.com/search/users', | ||
json: true, | ||
qs: { | ||
q: email + ' in:email' | ||
}, | ||
var qs = querystring.stringify({ | ||
q: email + ' in:email' | ||
}); | ||
got.get('https://api.github.com/search/users?' + qs, { | ||
headers: headers | ||
}, function (err, res, body) { | ||
if (err || res.statusCode !== 200) { | ||
return cb(err || new Error('Status code: ' + res.statusCode)); | ||
}, function (err, data) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
if (body.total_count === 0) { | ||
return cb(new Error('Couldn\'t find a username for the supplied email')); | ||
data = JSON.parse(data); | ||
if (data.total_count === 0) { | ||
cb(new Error('Couldn\'t find a username for the supplied email')); | ||
return; | ||
} | ||
cb(null, body.items[0].login); | ||
cb(null, data.items[0].login); | ||
}); | ||
}; |
{ | ||
"name": "github-username", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Get a GitHub username from an email address", | ||
@@ -26,2 +26,3 @@ "license": "MIT", | ||
"keywords": [ | ||
"cli-app", | ||
"cli", | ||
@@ -39,3 +40,3 @@ "bin", | ||
"get-stdin": "^1.0.0", | ||
"request": "^2.40.0" | ||
"got": "^2.3.0" | ||
}, | ||
@@ -42,0 +43,0 @@ "devDependencies": { |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
4896
29.94%5
25%87
2.35%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed