mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Support multiple rel="me"
This commit is contained in:
parent
5efbbcbeb1
commit
c627e6d834
2 changed files with 14 additions and 9 deletions
|
@ -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 () {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue