fix invalid banner url breaking profile

This commit is contained in:
Martti Malmi 2023-01-24 11:11:31 +02:00
parent adc1be08a8
commit 621bb46446
2 changed files with 16 additions and 10 deletions

View File

@ -477,13 +477,11 @@ export default {
</svg>
),
checkmark: (
(
<svg height="14" width="14" x="0px" y="0px" viewBox="0 0 191.667 191.667">
<path
fill="currentColor"
d="M95.833,0C42.991,0,0,42.99,0,95.833s42.991,95.834,95.833,95.834s95.833-42.991,95.833-95.834S148.676,0,95.833,0z M150.862,79.646l-60.207,60.207c-2.56,2.56-5.963,3.969-9.583,3.969c-3.62,0-7.023-1.409-9.583-3.969l-30.685-30.685 c-2.56-2.56-3.97-5.963-3.97-9.583c0-3.621,1.41-7.024,3.97-9.584c2.559-2.56,5.962-3.97,9.583-3.97c3.62,0,7.024,1.41,9.583,3.971 l21.101,21.1l50.623-50.623c2.56-2.56,5.963-3.969,9.583-3.969c3.62,0,7.023,1.409,9.583,3.969 C156.146,65.765,156.146,74.362,150.862,79.646z"
/>
</svg>
)
)
<svg height="14" width="14" x="0px" y="0px" viewBox="0 0 191.667 191.667">
<path
fill="currentColor"
d="M95.833,0C42.991,0,0,42.99,0,95.833s42.991,95.834,95.833,95.834s95.833-42.991,95.833-95.834S148.676,0,95.833,0z M150.862,79.646l-60.207,60.207c-2.56,2.56-5.963,3.969-9.583,3.969c-3.62,0-7.023-1.409-9.583-3.969l-30.685-30.685 c-2.56-2.56-3.97-5.963-3.97-9.583c0-3.621,1.41-7.024,3.97-9.584c2.559-2.56,5.962-3.97,9.583-3.97c3.62,0,7.024,1.41,9.583,3.971 l21.101,21.1l50.623-50.623c2.56-2.56,5.963-3.969,9.583-3.969c3.62,0,7.023,1.409,9.583,3.969 C156.146,65.765,156.146,74.362,150.862,79.646z"
/>
</svg>
),
};

View File

@ -412,6 +412,14 @@ class Profile extends View {
website = website.slice(0, -1);
}
let banner;
try {
banner = profile.banner && new URL(profile.banner).toString();
} catch (e) {
console.log('Invalid banner URL', profile.banner);
}
// profile may contain arbitrary fields, so be careful
this.setState({
name: profile.name,
@ -420,7 +428,7 @@ class Profile extends View {
nip05: profile.nip05valid && profile.nip05,
lud16,
website: website,
banner: profile.banner && new URL(profile.banner).toString(),
banner,
});
},
true,