all-contributors-cli/lib/contributors/github.js
Alex Jover a879de2a7f fix: non-http prepended urls (#35)
* Add editor config

* Fix non-http prepended urls

* Remove editorconfig

* Use startsWith and shorthand operator
2017-02-23 12:02:55 -07:00

25 lines
579 B
JavaScript

'use strict';
var pify = require('pify');
var request = pify(require('request'));
module.exports = function getUserInfo(username) {
return request.get({
url: 'https://api.github.com/users/' + username,
headers: {
'User-Agent': 'request'
}
})
.then(res => {
var body = JSON.parse(res.body);
var profile = body.blog || body.html_url;
profile = profile.startsWith('http') ? profile : 'http://' + profile;
return {
login: body.login,
name: body.name || username,
avatar_url: body.avatar_url,
profile
};
});
};