server: fix error for invalid URLs in profile fields
All checks were successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
All checks were successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
Co-authored-by: Chloe Kudryavtsev <code@code.bunkerlabs.net>
This commit is contained in:
parent
bb3ec8bafe
commit
2d32bc33d7
|
@ -30,12 +30,21 @@ export async function renderPerson(user: ILocalUser) {
|
||||||
|
|
||||||
if (profile.fields) {
|
if (profile.fields) {
|
||||||
for (const field of profile.fields) {
|
for (const field of profile.fields) {
|
||||||
|
let value = field.value;
|
||||||
|
// try to parse it as a url
|
||||||
|
try {
|
||||||
|
if (field.value?.match(/^https?:/)) {
|
||||||
|
const url = new URL(field.value);
|
||||||
|
value = `<a href="${url.href}" rel="me nofollow noopener" target="_blank">${url.href}</a>`;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// guess it wasn't a url after all...
|
||||||
|
}
|
||||||
|
|
||||||
attachment.push({
|
attachment.push({
|
||||||
type: 'PropertyValue',
|
type: 'PropertyValue',
|
||||||
name: field.name,
|
name: field.name,
|
||||||
value: (field.value != null && field.value.match(/^https?:/))
|
value,
|
||||||
? `<a href="${new URL(field.value).href}" rel="me nofollow noopener" target="_blank">${new URL(field.value).href}</a>`
|
|
||||||
: field.value,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue