mirror of https://github.com/Chocobozzz/PeerTube
Do not index remote actors
parent
da948b75ca
commit
352819ef92
|
@ -44,6 +44,8 @@ type Tags = {
|
||||||
originUrl: string
|
originUrl: string
|
||||||
description: string
|
description: string
|
||||||
|
|
||||||
|
disallowIndexation?: boolean
|
||||||
|
|
||||||
embed?: {
|
embed?: {
|
||||||
url: string
|
url: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
|
@ -285,7 +287,8 @@ class ClientHtml {
|
||||||
image,
|
image,
|
||||||
ogType,
|
ogType,
|
||||||
twitterCard,
|
twitterCard,
|
||||||
schemaType
|
schemaType,
|
||||||
|
disallowIndexation: !entity.Actor.isOwned()
|
||||||
})
|
})
|
||||||
|
|
||||||
return customHtml
|
return customHtml
|
||||||
|
@ -488,7 +491,7 @@ class ClientHtml {
|
||||||
const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues)
|
const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues)
|
||||||
const schemaTags = this.generateSchemaTags(tagsValues)
|
const schemaTags = this.generateSchemaTags(tagsValues)
|
||||||
|
|
||||||
const { url, title, embed, originUrl } = tagsValues
|
const { url, title, embed, originUrl, disallowIndexation } = tagsValues
|
||||||
|
|
||||||
const oembedLinkTags: { type: string, href: string, title: string }[] = []
|
const oembedLinkTags: { type: string, href: string, title: string }[] = []
|
||||||
|
|
||||||
|
@ -536,6 +539,10 @@ class ClientHtml {
|
||||||
// SEO, use origin URL
|
// SEO, use origin URL
|
||||||
tagsString += `<link rel="canonical" href="${originUrl}" />`
|
tagsString += `<link rel="canonical" href="${originUrl}" />`
|
||||||
|
|
||||||
|
if (disallowIndexation) {
|
||||||
|
tagsString += `<meta name="robots" content="noindex" />`
|
||||||
|
}
|
||||||
|
|
||||||
return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString)
|
return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,6 +445,40 @@ describe('Test a client controllers', function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should add noindex meta tag for remote accounts', async function () {
|
||||||
|
const handle = 'root@' + servers[0].host
|
||||||
|
const paths = [ '/accounts/', '/a/', '/@' ]
|
||||||
|
|
||||||
|
for (const path of paths) {
|
||||||
|
{
|
||||||
|
const { text } = await makeHTMLRequest(servers[1].url, path + handle)
|
||||||
|
expect(text).to.contain('<meta name="robots" content="noindex" />')
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const { text } = await makeHTMLRequest(servers[0].url, path + handle)
|
||||||
|
expect(text).to.not.contain('<meta name="robots" content="noindex" />')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should add noindex meta tag for remote accounts', async function () {
|
||||||
|
const handle = 'root_channel@' + servers[0].host
|
||||||
|
const paths = [ '/video-channels/', '/c/', '/@' ]
|
||||||
|
|
||||||
|
for (const path of paths) {
|
||||||
|
{
|
||||||
|
const { text } = await makeHTMLRequest(servers[1].url, path + handle)
|
||||||
|
expect(text).to.contain('<meta name="robots" content="noindex" />')
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const { text } = await makeHTMLRequest(servers[0].url, path + handle)
|
||||||
|
expect(text).to.not.contain('<meta name="robots" content="noindex" />')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Embed HTML', function () {
|
describe('Embed HTML', function () {
|
||||||
|
|
Loading…
Reference in New Issue