Commit 9ccac4ab authored by Hong Minhee's avatar Hong Minhee
Browse files

Merge tag '0.15.6' into 1.0-maintenance

Fedify 0.15.6
parents 11eac449 3fbf0f51
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -8,6 +8,11 @@ Version 1.0.8

To be released.

 -  Fixed a bug where default document loaders had thrown a `TypeError`
    with a message <q>Body is unusable: Body has already been read</q> or
    <q>Body already consumed</q> when the content type of the response was
    an HTML document and there's no link to a JSON-LD document.


Version 1.0.7
-------------
@@ -258,6 +263,17 @@ Released on September 26, 2024.
[#137]: https://github.com/dahlia/fedify/issues/137


Version 0.15.6
--------------

Released on November 12, 2024.

 -  Fixed a bug where default document loaders had thrown a `TypeError`
    with a message <q>Body is unusable: Body has already been read</q> or
    <q>Body already consumed</q> when the content type of the response was
    an HTML document and there's no link to a JSON-LD document.


Version 0.15.5
--------------

+27 −0
Original line number Diff line number Diff line
@@ -207,6 +207,33 @@ test("fetchDocumentLoader()", async (t) => {
    });
  });

  mf.mock("GET@/wrong-content-type", (_req) =>
    new Response(
      JSON.stringify({
        "@context": "https://www.w3.org/ns/activitystreams",
        id: "https://example.com/wrong-content-type",
        name: "Fetched object",
        type: "Object",
      }),
      { status: 200, headers: { "Content-Type": "text/html; charset=utf-8" } },
    ));

  await t.step("Wrong Content-Type", async () => {
    assertEquals(
      await fetchDocumentLoader("https://example.com/wrong-content-type"),
      {
        contextUrl: null,
        documentUrl: "https://example.com/wrong-content-type",
        document: {
          "@context": "https://www.w3.org/ns/activitystreams",
          id: "https://example.com/wrong-content-type",
          name: "Fetched object",
          type: "Object",
        },
      },
    );
  });

  mf.mock("GET@/404", (_req) => new Response("", { status: 404 }));

  await t.step("not ok", async () => {
+5 −5
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ async function getRemoteDocument(
      }
    }
  }
  let document: unknown;
  if (
    !jsonLd &&
    (contentType === "text/html" || contentType?.startsWith("text/html;") ||
@@ -185,6 +186,9 @@ async function getRemoteDocument(
        return await fetch(new URL(attribs.href, docUrl).href);
      }
    }
    document = JSON.parse(html);
  } else {
    document = await response.json();
  }
  logger.debug(
    "Fetched document: {status} {url} {headers}",
@@ -194,11 +198,7 @@ async function getRemoteDocument(
      headers: Object.fromEntries(response.headers.entries()),
    },
  );
  return {
    contextUrl,
    document: await response.json(),
    documentUrl,
  };
  return { contextUrl, document, documentUrl };
}

/**