From a073c912700e1ecda70a463f334f316dc62db7a4 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 12 Apr 2021 11:43:29 +0200 Subject: modify tests to support current behaviour regarding plaintext description --- server/lib/client-html.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'server/lib') diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 5485376d3..203bd3893 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts @@ -24,7 +24,7 @@ import { VideoChannelModel } from '../models/video/video-channel' import { getActivityStreamDuration } from '../models/video/video-format-utils' import { VideoPlaylistModel } from '../models/video/video-playlist' import { MAccountActor, MChannelActor } from '../types/models' -import { toSafeHtml } from '../helpers/markdown' +import { mdToPlainText } from '../helpers/markdown' type Tags = { ogType: string @@ -55,10 +55,6 @@ type Tags = { } } -const toPlainText = (content: string) => { - return toSafeHtml(content).replace(/<[^>]+>/g, '') -} - class ClientHtml { private static htmlCache: { [path: string]: string } = {} @@ -99,13 +95,13 @@ class ClientHtml { } let customHtml = ClientHtml.addTitleTag(html, escapeHTML(video.name)) - customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(video.description)) + customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(video.description)) const url = WEBSERVER.URL + video.getWatchStaticPath() const originUrl = video.url const title = escapeHTML(video.name) const siteName = escapeHTML(CONFIG.INSTANCE.NAME) - const description = toPlainText(video.description) + const description = mdToPlainText(video.description) const image = { url: WEBSERVER.URL + video.getPreviewStaticPath() @@ -157,13 +153,13 @@ class ClientHtml { } let customHtml = ClientHtml.addTitleTag(html, escapeHTML(videoPlaylist.name)) - customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(videoPlaylist.description)) + customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(videoPlaylist.description)) const url = videoPlaylist.getWatchUrl() const originUrl = videoPlaylist.url const title = escapeHTML(videoPlaylist.name) const siteName = escapeHTML(CONFIG.INSTANCE.NAME) - const description = toPlainText(videoPlaylist.description) + const description = mdToPlainText(videoPlaylist.description) const image = { url: videoPlaylist.getThumbnailUrl() @@ -241,13 +237,13 @@ class ClientHtml { } let customHtml = ClientHtml.addTitleTag(html, escapeHTML(entity.getDisplayName())) - customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(entity.description)) + customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(entity.description)) const url = entity.getLocalUrl() const originUrl = entity.Actor.url const siteName = escapeHTML(CONFIG.INSTANCE.NAME) const title = escapeHTML(entity.getDisplayName()) - const description = toPlainText(entity.description) + const description = mdToPlainText(entity.description) const image = { url: entity.Actor.getAvatarUrl(), @@ -383,7 +379,7 @@ class ClientHtml { } metaTags['og:url'] = tags.url - metaTags['og:description'] = tags.description + metaTags['og:description'] = mdToPlainText(tags.description) if (tags.embed) { metaTags['og:video:url'] = tags.embed.url @@ -399,7 +395,7 @@ class ClientHtml { private static generateStandardMetaTags (tags: Tags) { return { name: tags.title, - description: tags.description, + description: mdToPlainText(tags.description), image: tags.image.url } } -- cgit v1.2.3