Infer quote_id from links in status content

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-04-29 23:53:10 +02:00
parent 1d177831fe
commit 9668846ff0
6 changed files with 75 additions and 8 deletions

View File

@ -71,3 +71,13 @@ export const getActualStatus = <T extends { reblog: T | string | null }>(status:
return status;
}
};
export const getStatusIdsFromLinksInContent = (content: string): string[] => {
const urls = content.match(RegExp(`${window.location.origin}/@([a-z\\d_-]+(?:@[^@\\s]+)?)/posts/[a-z0-9]+(?!\\S)`, 'gi'));
if (!urls) return [];
return Array.from(new Set(urls
.map(url => url.split('/').at(-1) as string)
.filter(url => url)));
};