+ {integration?.identifier === 'linkedin' && (
+
+ )}
1 ? 200 : 250}
diff --git a/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts b/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts
index e1a1f8ba..bff40677 100644
--- a/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/linkedin.provider.ts
@@ -156,7 +156,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
async company(token: string, data: { url: string }) {
const { url } = data;
const getCompanyVanity = url.match(
- /^https?:\/\/?www\.?linkedin\.com\/company\/([^/]+)\/$/
+ /^https?:\/\/(?:www\.)?linkedin\.com\/company\/([^/]+)\/?$/
);
if (!getCompanyVanity || !getCompanyVanity?.length) {
throw new Error('Invalid LinkedIn company URL');
@@ -282,6 +282,32 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
}
}
+ private fixText(text: string) {
+ const pattern = /@\[.+?]\(urn:li:organization.+?\)/g;
+ const matches = text.match(pattern) || [];
+ const splitAll = text.split(pattern);
+ const splitTextReformat = splitAll.map((p) => {
+ return p
+ .replace(/\*/g, '\\*')
+ .replace(/\(/g, '\\(')
+ .replace(/\)/g, '\\)')
+ .replace(/\{/g, '\\{')
+ .replace(/}/g, '\\}')
+ .replace(/@/g, '\\@');
+ });
+
+ const connectAll = splitTextReformat.reduce((all, current) => {
+ const match = matches.shift();
+ all.push(current);
+ if (match) {
+ all.push(match);
+ }
+ return all;
+ }, [] as string[]);
+
+ return connectAll.join('');
+ }
+
async post(
id: string,
accessToken: string,
@@ -340,12 +366,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
type === 'personal'
? `urn:li:person:${id}`
: `urn:li:organization:${id}`,
- commentary: firstPost.message
- .replace(/\*/g, '\\*')
- .replace(/\(/g, '\\(')
- .replace(/\)/g, '\\)')
- .replace(/\{/g, '\\{')
- .replace(/}/g, '\\}'),
+ commentary: this.fixText(firstPost.message),
visibility: 'PUBLIC',
distribution: {
feedDistribution: 'MAIN_FEED',
@@ -410,12 +431,7 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
? `urn:li:person:${id}`
: `urn:li:organization:${id}`,
object: topPostId,
- message: post.message
- .replace(/\*/g, '\\*')
- .replace(/\(/g, '\\(')
- .replace(/\)/g, '\\)')
- .replace(/\{/g, '\\{')
- .replace(/}/g, '\\}'),
+ message: this.fixText(post.message),
}),
}
)