Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Support multiple rel="me"

Chocobozzzc627e6d834ff
diff --git a/packages/tests/src/client/head-tags.ts b/packages/tests/src/client/head-tags.ts
index 3bbc59cd64..8176f8dfcc 100644
--- a/packages/tests/src/client/head-tags.ts
+++ b/packages/tests/src/client/head-tags.ts
@@ -238,11 +238,11 @@ describe('Test <head> HTML tags', function () {
})
describe('Mastodon link', function () {
- async function check (path: string, mastoLink: string, exist = true) {
+ async function check (path: string, href: string, exist = true) {
const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
- const expected = `<link href="${mastoLink}" rel="me">`
+ const expected = `<link href="${href}" rel="me">`
if (exist) expect(text).to.contain(expected)
else expect(text).to.not.contain(expected)
@@ -250,10 +250,12 @@ describe('Test <head> HTML tags', function () {
it('Should correctly include Mastodon link in account', async function () {
await servers[0].users.updateMe({
- description: 'hi, please <a href="https://social.example.com/@username" rel="me">Follow me on Mastodon!</a>'
+ description: 'hi, please <a href="https://social.example.com/@username" rel="me">Follow me on Mastodon!</a> and ' +
+ '<a href="https://social.example.com/@username2" rel="me">Follow me on Mastodon 2!</a>'
})
await check('/a/root', 'https://social.example.com/@username')
+ await check('/a/root', 'https://social.example.com/@username2')
})
it('Should correctly include Mastodon link in channel', async function () {
diff --git a/server/core/lib/html/shared/tags-html.ts b/server/core/lib/html/shared/tags-html.ts
index 74a8cc7b01..d1007beb7d 100644
--- a/server/core/lib/html/shared/tags-html.ts
+++ b/server/core/lib/html/shared/tags-html.ts
@@ -30,7 +30,7 @@ export type TagsOptions = {
escapedTitle?: string
escapedTruncatedDescription?: string
- relMe?: string
+ relMe?: string[]
image?: {
url: string
@@ -59,7 +59,6 @@ type HookContext = {
}
export class TagsHtml {
-
static addTitleTag (htmlStringPage: string, title?: string) {
let text = title || CONFIG.INSTANCE.NAME
if (title) text += ` - ${CONFIG.INSTANCE.NAME}`
@@ -81,7 +80,7 @@ export class TagsHtml {
const html = parse(content)
- return html.querySelector('a[rel=me]')?.getAttribute('href') || undefined
+ return html.querySelectorAll('a[rel=me]').map(e => e.getAttribute('href'))
}
// ---------------------------------------------------------------------------
@@ -118,7 +117,9 @@ export class TagsHtml {
// OEmbed
for (const oembedLinkTag of oembedLinkTags) {
// eslint-disable-next-line max-len
- tagsStr += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${escapeAttribute(oembedLinkTag.escapedTitle)}" />`
+ tagsStr += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${
+ escapeAttribute(oembedLinkTag.escapedTitle)
+ }" />`
}
// Schema.org
@@ -126,8 +127,10 @@ export class TagsHtml {
tagsStr += `<script type="application/ld+json">${JSON.stringify(schemaTags)}</script>`
}
- if (relMe) {
- tagsStr += `<link href="${escapeAttribute(relMe)}" rel="me">`
+ if (Array.isArray(relMe)) {
+ for (const relMeLink of relMe) {
+ tagsStr += `<link href="${escapeAttribute(relMeLink)}" rel="me">`
+ }
}
// SEO, use origin URL