mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* Add missing JSDoc to exported members in app and server utils Documents all exported functions, classes, enums, and constants in app/utils and server/utils that were missing JSDoc, per the project documentation guidelines. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AsEQYA8zN813thxu7GjjzU * Use @returns tag to match codebase convention Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AsEQYA8zN813thxu7GjjzU --------- Co-authored-by: Claude <noreply@anthropic.com>
27 lines
713 B
TypeScript
27 lines
713 B
TypeScript
import { compact, uniq } from "es-toolkit/compat";
|
|
import {
|
|
attachmentPublicRegex,
|
|
attachmentRedirectRegex,
|
|
} from "@shared/utils/ProsemirrorHelper";
|
|
|
|
/**
|
|
* Parses the unique attachment ids from attachment URLs in a text.
|
|
*
|
|
* @param text the text to parse.
|
|
* @param includePublic whether to also include public attachment URLs.
|
|
* @returns an array of unique attachment ids.
|
|
*/
|
|
export default function parseAttachmentIds(
|
|
text: string,
|
|
includePublic = false
|
|
): string[] {
|
|
return uniq(
|
|
compact(
|
|
[
|
|
...text.matchAll(attachmentRedirectRegex),
|
|
...(includePublic ? text.matchAll(attachmentPublicRegex) : []),
|
|
].map((match) => match.groups && match.groups.id)
|
|
)
|
|
);
|
|
}
|