Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/contributors/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ module.exports = function getUserInfo(username) {
})
.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: body.blog || body.html_url
profile
};
});
};
16 changes: 16 additions & 0 deletions lib/contributors/github.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,19 @@ test('should fill in the name when an empty string is returned', t => {
t.is(info.name, 'nodisplayname');
});
});

test('should append http when no absolute link is provided', t => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

nock('https://api.github.com')
.get('/users/nodisplayname')
.reply(200, {
login: 'nodisplayname',
name: '',
avatar_url: 'https://avatars2.githubusercontent.com/u/3869412?v=3&s=400',
html_url: 'www.github.com/nodisplayname'
});

return getUserInfo('nodisplayname')
.then(info => {
t.is(info.profile, 'http://www.github.com/nodisplayname');
});
});