Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double spaced tweets in Post.ts #1626

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
monilpat marked this conversation as resolved.
Show resolved Hide resolved
}

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
monilpat marked this conversation as resolved.
Show resolved Hide resolved

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