summaryrefslogtreecommitdiff
path: root/packages/frontend/src/utility/extract-preview-urls.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/utility/extract-preview-urls.ts')
-rw-r--r--packages/frontend/src/utility/extract-preview-urls.ts29
1 files changed, 6 insertions, 23 deletions
diff --git a/packages/frontend/src/utility/extract-preview-urls.ts b/packages/frontend/src/utility/extract-preview-urls.ts
index 5fc9c87a32..264359f179 100644
--- a/packages/frontend/src/utility/extract-preview-urls.ts
+++ b/packages/frontend/src/utility/extract-preview-urls.ts
@@ -3,35 +3,18 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
-import * as config from '@@/js/config.js';
import type * as Misskey from 'misskey-js';
-import type * as mfm from '@transfem-org/sfm-js';
+import type * as mfm from 'mfm-js';
import { extractUrlFromMfm } from '@/utility/extract-url-from-mfm.js';
+import { getNoteUrls } from '@/utility/getNoteUrls';
/**
* Extracts all previewable URLs from a note.
*/
export function extractPreviewUrls(note: Misskey.entities.Note, contents: mfm.MfmNode[]): string[] {
const links = extractUrlFromMfm(contents);
- return links.filter(url =>
- // Remote note
- url !== note.url &&
- url !== note.uri &&
- // Local note
- url !== `${config.url}/notes/${note.id}` &&
- // Remote reply
- url !== note.reply?.url &&
- url !== note.reply?.uri &&
- // Local reply
- url !== `${config.url}/notes/${note.reply?.id}` &&
- // Remote renote or quote
- url !== note.renote?.url &&
- url !== note.renote?.uri &&
- // Local renote or quote
- url !== `${config.url}/notes/${note.renote?.id}` &&
- // Remote renote *of* a quote
- url !== note.renote?.renote?.url &&
- url !== note.renote?.renote?.uri &&
- // Local renote *of* a quote
- url !== `${config.url}/notes/${note.renote?.renote?.id}`);
+ if (links.length < 0) return [];
+
+ const self = getNoteUrls(note);
+ return links.filter(url => !self.includes(url));
}