mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-21 17:37:29 -07:00
[backend] Only render trailing slashes for URLs in profile fields when explicitly specified
This commit is contained in:
parent
9167ba593c
commit
f843453ca0
1 changed files with 8 additions and 7 deletions
|
@ -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 a new issue