From bbdb84c483efb24551ebb5b516feea86fcd1a7fe Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Sat, 5 Oct 2024 20:54:10 +0100 Subject: [PATCH] feat: ignore media properties --- lib/fetch-references.js | 4 +++- test/fetch-references.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/fetch-references.js b/lib/fetch-references.js index 8a9a920..5f7e59c 100644 --- a/lib/fetch-references.js +++ b/lib/fetch-references.js @@ -1,6 +1,8 @@ import { mf2tojf2 } from "../index.js"; import { fetchMf2 } from "./fetch-mf2.js"; +const ignoredProperties = new Set(["audio", "photo", "url", "video"]); + /** * Get a list of URLs that can be referenced * @private @@ -16,7 +18,7 @@ const referenceableUrls = (jf2) => { const referenceableProperty = typeof value === "string" && URL.canParse(value) && - key !== "url" && + !ignoredProperties.has(key) && !key.startsWith("mp-"); if (referenceableProperty) { diff --git a/test/fetch-references.js b/test/fetch-references.js index 7bfa878..9999d99 100644 --- a/test/fetch-references.js +++ b/test/fetch-references.js @@ -12,6 +12,7 @@ describe("mf2tojf2", () => { type: "entry", name: "What my friend ate for lunch yesterday", published: "2019-02-12T10:00:00.000+00:00", + photo: "https://website.example/photo.jpg", category: ["foo", "bar"], url: "https://website.example/bookmarks/lunch", "bookmark-of": "https://another.example/notes/lunch", @@ -22,6 +23,7 @@ describe("mf2tojf2", () => { type: "entry", name: "What my friend ate for lunch yesterday", published: "2019-02-12T10:00:00.000+00:00", + photo: "https://website.example/photo.jpg", category: ["foo", "bar"], url: "https://website.example/bookmarks/lunch", "bookmark-of": "https://another.example/notes/lunch",