aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/core-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-10-21 09:48:21 +0200
committerChocobozzz <me@florianbigard.com>2019-10-21 09:52:51 +0200
commit687c6180bc5f48b9159bbb229ec5404cc205919e (patch)
tree31e5c628baf96238a644da7e0b6affc597019fc5 /server/helpers/core-utils.ts
parent4386e66e5538b6336be7cbcbe70bcb1909a1afdc (diff)
downloadPeerTube-687c6180bc5f48b9159bbb229ec5404cc205919e.tar.gz
PeerTube-687c6180bc5f48b9159bbb229ec5404cc205919e.tar.zst
PeerTube-687c6180bc5f48b9159bbb229ec5404cc205919e.zip
Fix federation issue with some actor descriptions
Diffstat (limited to 'server/helpers/core-utils.ts')
-rw-r--r--server/helpers/core-utils.ts9
1 files changed, 3 insertions, 6 deletions
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index 9ff67c43a..7e8252aa4 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -179,18 +179,15 @@ function buildPath (path: string) {
179} 179}
180 180
181// Consistent with .length, lodash truncate function is not 181// Consistent with .length, lodash truncate function is not
182function peertubeTruncate (str: string, maxLength: number) { 182function peertubeTruncate (str: string, options: { length: number, separator?: RegExp, omission?: string }) {
183 const options = {
184 length: maxLength
185 }
186 const truncatedStr = truncate(str, options) 183 const truncatedStr = truncate(str, options)
187 184
188 // The truncated string is okay, we can return it 185 // The truncated string is okay, we can return it
189 if (truncatedStr.length <= maxLength) return truncatedStr 186 if (truncatedStr.length <= options.length) return truncatedStr
190 187
191 // Lodash takes into account all UTF characters, whereas String.prototype.length does not: some characters have a length of 2 188 // Lodash takes into account all UTF characters, whereas String.prototype.length does not: some characters have a length of 2
192 // We always use the .length so we need to truncate more if needed 189 // We always use the .length so we need to truncate more if needed
193 options.length -= truncatedStr.length - maxLength 190 options.length -= truncatedStr.length - options.length
194 return truncate(str, options) 191 return truncate(str, options)
195} 192}
196 193