Skip to content

Commit

Permalink
fix: handle special characters in post content
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperKoza343 committed Jan 21, 2025
1 parent b59503e commit a1a62c5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/client-linkedin/src/services/PostContentCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ export class PostContentCreator {
modelClass: ModelClass.SMALL,
});

return removeMd(text);
return this.removeMd(this.escapeSpecialCharacters(text));
}

removeMd(content: string) {
return removeMd(content);
}

escapeSpecialCharacters(content: string): string {
const escapedCharacters = content
.replace(/\(/g, "\\(")
.replace(/\)/g, "\\)")
.replace(/\[/g, "\\[")
.replace(/\]/g, "\\]")
.replace(/\{/g, "\\{")
.replace(/\}/g, "\\}");

return escapedCharacters;
}
}

0 comments on commit a1a62c5

Please sign in to comment.