Skip to content

Commit

Permalink
Merge pull request #1626 from suicidalgoofy/newline/tweets-newline-up…
Browse files Browse the repository at this point in the history
…date

Fix double spaced tweets in Post.ts
  • Loading branch information
monilpat authored Jan 1, 2025
2 parents 30cc542 + d17fef1 commit 64cfc07
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/client-twitter/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export class TwitterPostClient {
.replace(/^\s*{?\s*"text":\s*"|"\s*}?\s*$/g, "") // Remove JSON-like wrapper
.replace(/^['"](.*)['"]$/g, "$1") // Remove quotes
.replace(/\\"/g, '"') // Unescape quotes
.replace(/\\n/g, "\n") // Unescape newlines
.replace(/\\n/g, "\n\n") // Unescape newlines, ensures double spaces
.trim();
}

Expand All @@ -491,7 +491,7 @@ export class TwitterPostClient {
const removeQuotes = (str: string) =>
str.replace(/^['"](.*)['"]$/, "$1");

const fixNewLines = (str: string) => str.replaceAll(/\\n/g, "\n");
const fixNewLines = (str: string) => str.replaceAll(/\\n/g, "\n\n"); //ensures double spaces

// Final cleaning
cleanedContent = removeQuotes(fixNewLines(cleanedContent));
Expand Down

0 comments on commit 64cfc07

Please sign in to comment.