aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 4e175c410..f43b73e49 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1166,10 +1166,19 @@ export class VideoModel extends Model<VideoModel> {
1166 getTruncatedDescription () { 1166 getTruncatedDescription () {
1167 if (!this.description) return null 1167 if (!this.description) return null
1168 1168
1169 const maxLength = CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max
1170
1169 const options = { 1171 const options = {
1170 length: CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max 1172 length: maxLength
1171 } 1173 }
1174 const truncatedDescription = truncate(this.description, options)
1175
1176 // The truncated string is okay, we can return it
1177 if (truncatedDescription.length <= maxLength) return truncatedDescription
1172 1178
1179 // Lodash takes into account all UTF characters, whereas String.prototype.length does not: some characters have a length of 2
1180 // We always use the .length so we need to truncate more if needed
1181 options.length -= maxLength - truncatedDescription.length
1173 return truncate(this.description, options) 1182 return truncate(this.description, options)
1174 } 1183 }
1175 1184