diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-04-12 11:43:29 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-04-13 15:45:09 +0200 |
commit | a073c912700e1ecda70a463f334f316dc62db7a4 (patch) | |
tree | 46dfa8d014765ef8baba9251c15485a545082f91 /server/lib/client-html.ts | |
parent | 84bced652cd72aad852914a4a734c47dd0002fef (diff) | |
download | PeerTube-a073c912700e1ecda70a463f334f316dc62db7a4.tar.gz PeerTube-a073c912700e1ecda70a463f334f316dc62db7a4.tar.zst PeerTube-a073c912700e1ecda70a463f334f316dc62db7a4.zip |
modify tests to support current behaviour regarding plaintext description
Diffstat (limited to 'server/lib/client-html.ts')
-rw-r--r-- | server/lib/client-html.ts | 22 |
1 files changed, 9 insertions, 13 deletions
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' | |||
24 | import { getActivityStreamDuration } from '../models/video/video-format-utils' | 24 | import { getActivityStreamDuration } from '../models/video/video-format-utils' |
25 | import { VideoPlaylistModel } from '../models/video/video-playlist' | 25 | import { VideoPlaylistModel } from '../models/video/video-playlist' |
26 | import { MAccountActor, MChannelActor } from '../types/models' | 26 | import { MAccountActor, MChannelActor } from '../types/models' |
27 | import { toSafeHtml } from '../helpers/markdown' | 27 | import { mdToPlainText } from '../helpers/markdown' |
28 | 28 | ||
29 | type Tags = { | 29 | type Tags = { |
30 | ogType: string | 30 | ogType: string |
@@ -55,10 +55,6 @@ type Tags = { | |||
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | const toPlainText = (content: string) => { | ||
59 | return toSafeHtml(content).replace(/<[^>]+>/g, '') | ||
60 | } | ||
61 | |||
62 | class ClientHtml { | 58 | class ClientHtml { |
63 | 59 | ||
64 | private static htmlCache: { [path: string]: string } = {} | 60 | private static htmlCache: { [path: string]: string } = {} |
@@ -99,13 +95,13 @@ class ClientHtml { | |||
99 | } | 95 | } |
100 | 96 | ||
101 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(video.name)) | 97 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(video.name)) |
102 | customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(video.description)) | 98 | customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(video.description)) |
103 | 99 | ||
104 | const url = WEBSERVER.URL + video.getWatchStaticPath() | 100 | const url = WEBSERVER.URL + video.getWatchStaticPath() |
105 | const originUrl = video.url | 101 | const originUrl = video.url |
106 | const title = escapeHTML(video.name) | 102 | const title = escapeHTML(video.name) |
107 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) | 103 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) |
108 | const description = toPlainText(video.description) | 104 | const description = mdToPlainText(video.description) |
109 | 105 | ||
110 | const image = { | 106 | const image = { |
111 | url: WEBSERVER.URL + video.getPreviewStaticPath() | 107 | url: WEBSERVER.URL + video.getPreviewStaticPath() |
@@ -157,13 +153,13 @@ class ClientHtml { | |||
157 | } | 153 | } |
158 | 154 | ||
159 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(videoPlaylist.name)) | 155 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(videoPlaylist.name)) |
160 | customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(videoPlaylist.description)) | 156 | customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(videoPlaylist.description)) |
161 | 157 | ||
162 | const url = videoPlaylist.getWatchUrl() | 158 | const url = videoPlaylist.getWatchUrl() |
163 | const originUrl = videoPlaylist.url | 159 | const originUrl = videoPlaylist.url |
164 | const title = escapeHTML(videoPlaylist.name) | 160 | const title = escapeHTML(videoPlaylist.name) |
165 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) | 161 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) |
166 | const description = toPlainText(videoPlaylist.description) | 162 | const description = mdToPlainText(videoPlaylist.description) |
167 | 163 | ||
168 | const image = { | 164 | const image = { |
169 | url: videoPlaylist.getThumbnailUrl() | 165 | url: videoPlaylist.getThumbnailUrl() |
@@ -241,13 +237,13 @@ class ClientHtml { | |||
241 | } | 237 | } |
242 | 238 | ||
243 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(entity.getDisplayName())) | 239 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(entity.getDisplayName())) |
244 | customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(entity.description)) | 240 | customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(entity.description)) |
245 | 241 | ||
246 | const url = entity.getLocalUrl() | 242 | const url = entity.getLocalUrl() |
247 | const originUrl = entity.Actor.url | 243 | const originUrl = entity.Actor.url |
248 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) | 244 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) |
249 | const title = escapeHTML(entity.getDisplayName()) | 245 | const title = escapeHTML(entity.getDisplayName()) |
250 | const description = toPlainText(entity.description) | 246 | const description = mdToPlainText(entity.description) |
251 | 247 | ||
252 | const image = { | 248 | const image = { |
253 | url: entity.Actor.getAvatarUrl(), | 249 | url: entity.Actor.getAvatarUrl(), |
@@ -383,7 +379,7 @@ class ClientHtml { | |||
383 | } | 379 | } |
384 | 380 | ||
385 | metaTags['og:url'] = tags.url | 381 | metaTags['og:url'] = tags.url |
386 | metaTags['og:description'] = tags.description | 382 | metaTags['og:description'] = mdToPlainText(tags.description) |
387 | 383 | ||
388 | if (tags.embed) { | 384 | if (tags.embed) { |
389 | metaTags['og:video:url'] = tags.embed.url | 385 | metaTags['og:video:url'] = tags.embed.url |
@@ -399,7 +395,7 @@ class ClientHtml { | |||
399 | private static generateStandardMetaTags (tags: Tags) { | 395 | private static generateStandardMetaTags (tags: Tags) { |
400 | return { | 396 | return { |
401 | name: tags.title, | 397 | name: tags.title, |
402 | description: tags.description, | 398 | description: mdToPlainText(tags.description), |
403 | image: tags.image.url | 399 | image: tags.image.url |
404 | } | 400 | } |
405 | } | 401 | } |