Skip to content

Commit 859d959

Browse files
committed
truncate extracted text
1 parent 10fa7eb commit 859d959

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/client-twitter/src/post.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,10 @@ export class TwitterPostClient {
558558
}
559559

560560
if (!cleanedContent) {
561-
cleanedContent = extractAttributes(newTweetContent, [
562-
"text",
563-
]).text;
561+
cleanedContent = truncateToCompleteSentence(
562+
extractAttributes(newTweetContent, ["text"]).text,
563+
this.client.twitterConfig.MAX_TWEET_LENGTH,
564+
);
564565
}
565566

566567
if (!cleanedContent) {
@@ -688,7 +689,10 @@ export class TwitterPostClient {
688689
);
689690
}
690691

691-
let truncateContent = extractAttributes(cleanedResponse, ["text"]).text;
692+
let truncateContent = truncateToCompleteSentence(
693+
extractAttributes(cleanedResponse, ["text"]).text,
694+
this.client.twitterConfig.MAX_TWEET_LENGTH,
695+
);
692696

693697
if (!truncateContent) {
694698
// If not JSON or no valid content found, clean the raw text

0 commit comments

Comments
 (0)