diff options
-rw-r--r-- | server/lib/client-html.ts | 11 | ||||
-rw-r--r-- | server/tests/client.ts | 34 |
2 files changed, 43 insertions, 2 deletions
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index a557c090f..e093d35f7 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -44,6 +44,8 @@ type Tags = { | |||
44 | originUrl: string | 44 | originUrl: string |
45 | description: string | 45 | description: string |
46 | 46 | ||
47 | disallowIndexation?: boolean | ||
48 | |||
47 | embed?: { | 49 | embed?: { |
48 | url: string | 50 | url: string |
49 | createdAt: string | 51 | createdAt: string |
@@ -285,7 +287,8 @@ class ClientHtml { | |||
285 | image, | 287 | image, |
286 | ogType, | 288 | ogType, |
287 | twitterCard, | 289 | twitterCard, |
288 | schemaType | 290 | schemaType, |
291 | disallowIndexation: !entity.Actor.isOwned() | ||
289 | }) | 292 | }) |
290 | 293 | ||
291 | return customHtml | 294 | return customHtml |
@@ -488,7 +491,7 @@ class ClientHtml { | |||
488 | const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues) | 491 | const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues) |
489 | const schemaTags = this.generateSchemaTags(tagsValues) | 492 | const schemaTags = this.generateSchemaTags(tagsValues) |
490 | 493 | ||
491 | const { url, title, embed, originUrl } = tagsValues | 494 | const { url, title, embed, originUrl, disallowIndexation } = tagsValues |
492 | 495 | ||
493 | const oembedLinkTags: { type: string, href: string, title: string }[] = [] | 496 | const oembedLinkTags: { type: string, href: string, title: string }[] = [] |
494 | 497 | ||
@@ -536,6 +539,10 @@ class ClientHtml { | |||
536 | // SEO, use origin URL | 539 | // SEO, use origin URL |
537 | tagsString += `<link rel="canonical" href="${originUrl}" />` | 540 | tagsString += `<link rel="canonical" href="${originUrl}" />` |
538 | 541 | ||
542 | if (disallowIndexation) { | ||
543 | tagsString += `<meta name="robots" content="noindex" />` | ||
544 | } | ||
545 | |||
539 | return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString) | 546 | return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString) |
540 | } | 547 | } |
541 | } | 548 | } |
diff --git a/server/tests/client.ts b/server/tests/client.ts index 4cbdb2cb3..4f0d052c8 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts | |||
@@ -445,6 +445,40 @@ describe('Test a client controllers', function () { | |||
445 | } | 445 | } |
446 | } | 446 | } |
447 | }) | 447 | }) |
448 | |||
449 | it('Should add noindex meta tag for remote accounts', async function () { | ||
450 | const handle = 'root@' + servers[0].host | ||
451 | const paths = [ '/accounts/', '/a/', '/@' ] | ||
452 | |||
453 | for (const path of paths) { | ||
454 | { | ||
455 | const { text } = await makeHTMLRequest(servers[1].url, path + handle) | ||
456 | expect(text).to.contain('<meta name="robots" content="noindex" />') | ||
457 | } | ||
458 | |||
459 | { | ||
460 | const { text } = await makeHTMLRequest(servers[0].url, path + handle) | ||
461 | expect(text).to.not.contain('<meta name="robots" content="noindex" />') | ||
462 | } | ||
463 | } | ||
464 | }) | ||
465 | |||
466 | it('Should add noindex meta tag for remote accounts', async function () { | ||
467 | const handle = 'root_channel@' + servers[0].host | ||
468 | const paths = [ '/video-channels/', '/c/', '/@' ] | ||
469 | |||
470 | for (const path of paths) { | ||
471 | { | ||
472 | const { text } = await makeHTMLRequest(servers[1].url, path + handle) | ||
473 | expect(text).to.contain('<meta name="robots" content="noindex" />') | ||
474 | } | ||
475 | |||
476 | { | ||
477 | const { text } = await makeHTMLRequest(servers[0].url, path + handle) | ||
478 | expect(text).to.not.contain('<meta name="robots" content="noindex" />') | ||
479 | } | ||
480 | } | ||
481 | }) | ||
448 | }) | 482 | }) |
449 | 483 | ||
450 | describe('Embed HTML', function () { | 484 | describe('Embed HTML', function () { |