Files
outline/server/utils/parseAttachmentIds.ts
2021-12-05 19:31:08 -08:00

12 lines
360 B
TypeScript

import { compact } from "lodash";
const attachmentRegex = /\/api\/attachments\.redirect\?id=(?<id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/gi;
export default function parseAttachmentIds(text: string): string[] {
return compact(
[...text.matchAll(attachmentRegex)].map(
(match) => match.groups && match.groups.id
)
);
}