Skip to content

Commit 4fd6293

Browse files
authored
Merge pull request #1490 from alphagov/fix-avatars
2 parents 662bb87 + e1977a1 commit 4fd6293

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/models/user.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ module.exports = function (sequelize, DataTypes) {
115115
else photo += '?size=bigger'
116116
break
117117
case 'github':
118-
if (profile.photos && profile.photos[0]) photo = profile.photos[0].value.replace('?', '')
119-
else photo = 'https://avatars.githubusercontent.com/u/' + profile.id
120-
if (bigger) photo += '?s=400'
121-
else photo += '?s=96'
118+
const photoURL = new URL(profile.photos && profile.photos[0]
119+
? profile.photos[0].value
120+
: `https://avatars.githubusercontent.com/u/${profile.id}`)
121+
photoURL.searchParams.set('s', bigger ? 400 : 96)
122+
photo = photoURL.toString()
122123
break
123124
case 'gitlab':
124125
photo = profile.avatarUrl

0 commit comments

Comments
 (0)