mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 00:43:49 +01:00
[backend] Only render trailing slashes for URLs in profile fields when explicitly specified
This commit is contained in:
parent
9167ba593c
commit
f843453ca0
@ -35,16 +35,17 @@ export async function renderPerson(user: ILocalUser) {
|
||||
|
||||
if (profile.fields) {
|
||||
for (const field of profile.fields) {
|
||||
if (field.value?.match(/^https?:\/\//)) {
|
||||
const hasTrailingSlash = field.value.endsWith('/');
|
||||
field.value = new URL(field.value).href;
|
||||
if (field.value.endsWith('/') && !hasTrailingSlash) field.value = field.value.slice(0, -1);
|
||||
field.value = `<a href="${field.value}" rel="me nofollow noopener" target="_blank">${field.value}</a>`;
|
||||
}
|
||||
|
||||
attachment.push({
|
||||
type: "PropertyValue",
|
||||
name: field.name,
|
||||
value: field.value?.match(/^https?:/)
|
||||
? `<a href="${
|
||||
new URL(field.value).href
|
||||
}" rel="me nofollow noopener" target="_blank">${
|
||||
new URL(field.value).href
|
||||
}</a>`
|
||||
: field.value,
|
||||
value: field.value,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user