mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-22 04:03: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) {
|
if (profile.fields) {
|
||||||
for (const field of 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({
|
attachment.push({
|
||||||
type: "PropertyValue",
|
type: "PropertyValue",
|
||||||
name: field.name,
|
name: field.name,
|
||||||
value: field.value?.match(/^https?:/)
|
value: field.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 New Issue
Block a user