mirror of https://github.com/status-im/codimd.git
Fix GitHub's avatar URL
At the moment, the URL is being composed and modified with the use of string composition. This causes issues, if the URL returned by GitHub slightly differs from the time developer initially had a look into it. In our case, the URL from GitHub has two query parameters in it, whilst the codebase only expected one. This change will take all of these parameters and only set the one we care about, whilst leaving others intact and carry on with the full URL. Fixes #1489 Signed-off-by: Rafal Proszowski <paroxp@gmail.com>
This commit is contained in:
parent
d7cc95129d
commit
e1977a1da7
|
@ -115,10 +115,11 @@ module.exports = function (sequelize, DataTypes) {
|
|||
else photo += '?size=bigger'
|
||||
break
|
||||
case 'github':
|
||||
if (profile.photos && profile.photos[0]) photo = profile.photos[0].value.replace('?', '')
|
||||
else photo = 'https://avatars.githubusercontent.com/u/' + profile.id
|
||||
if (bigger) photo += '?s=400'
|
||||
else photo += '?s=96'
|
||||
const photoURL = new URL(profile.photos && profile.photos[0]
|
||||
? profile.photos[0].value
|
||||
: `https://avatars.githubusercontent.com/u/${profile.id}`)
|
||||
photoURL.searchParams.set('s', bigger ? 400 : 96)
|
||||
photo = photoURL.toString()
|
||||
break
|
||||
case 'gitlab':
|
||||
photo = profile.avatarUrl
|
||||
|
|
Loading…
Reference in New Issue