Unverified Commit 2bcc9745 authored by Hong Minhee's avatar Hong Minhee
Browse files

Merge tag '1.0.6' into 1.1-maintenance

Fedify 1.0.6
parents 3c8ac732 18c906e3
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -8,6 +8,11 @@ Version 1.1.2

To be released.

 -  Fixed default document loaders' incorrect handling of relative URIs in
    `Link` headers with `rel=alternate`.  [[#155] by Emelia Smith]
 -  The `fetchDocumentLoader()` function now preloads the following JSON-LD
    context: <http://schema.org/>.


Version 1.1.1
-------------
@@ -118,6 +123,17 @@ Released on October 20, 2024.
[#150]: https://github.com/dahlia/fedify/issues/150


Version 1.0.6
-------------

Released on October 27, 2024.

 -  Fixed default document loaders' incorrect handling of relative URIs in
    `Link` headers with `rel=alternate`.  [[#155] by Emelia Smith]
 -  The `fetchDocumentLoader()` function now preloads the following JSON-LD
    context: <http://schema.org/>.


Version 1.0.5
-------------

@@ -346,6 +362,19 @@ Released on September 26, 2024.
[#137]: https://github.com/dahlia/fedify/issues/137


Version 0.15.4
--------------

Released on October 27, 2024.

 -  Fixed default document loaders' incorrect handling of relative URIs in
    `Link` headers with `rel=alternate`.  [[#155] by Emelia Smith]
 -  The `fetchDocumentLoader()` function now preloads the following JSON-LD
    context: <http://schema.org/>.

[#155]: https://github.com/dahlia/fedify/pull/155


Version 0.15.3
--------------

@@ -1904,4 +1933,4 @@ Version 0.1.0

Initial release.  Released on March 8, 2024.

<!-- cSpell: ignore Dogeon Fabien Wressell -->
<!-- cSpell: ignore Dogeon Fabien Wressell Emelia -->
+3369 −0

File changed.

Preview size limit exceeded, changes collapsed.

+39 −0
Original line number Diff line number Diff line
@@ -83,6 +83,19 @@ test("fetchDocumentLoader()", async (t) => {
      },
    ));

  mf.mock("GET@/link-obj-relative", (_req) =>
    new Response(
      "",
      {
        status: 200,
        headers: {
          "Content-Type": "text/html; charset=utf-8",
          Link: '</object>; rel="alternate"; ' +
            'type="application/activity+json"',
        },
      },
    ));

  await t.step("Link header", async () => {
    assertEquals(await fetchDocumentLoader("https://example.com/link-ctx"), {
      contextUrl: "https://www.w3.org/ns/activitystreams",
@@ -106,6 +119,32 @@ test("fetchDocumentLoader()", async (t) => {
    });
  });

  await t.step("Link header relative url", async () => {
    assertEquals(await fetchDocumentLoader("https://example.com/link-ctx"), {
      contextUrl: "https://www.w3.org/ns/activitystreams",
      documentUrl: "https://example.com/link-ctx",
      document: {
        id: "https://example.com/link-ctx",
        name: "Fetched object",
        type: "Object",
      },
    });

    assertEquals(
      await fetchDocumentLoader("https://example.com/link-obj-relative"),
      {
        contextUrl: null,
        documentUrl: "https://example.com/object",
        document: {
          "@context": "https://www.w3.org/ns/activitystreams",
          id: "https://example.com/object",
          name: "Fetched object",
          type: "Object",
        },
      },
    );
  });

  mf.mock("GET@/html-link", (_req) =>
    new Response(
      `<html>
+4 −3
Original line number Diff line number Diff line
@@ -133,18 +133,19 @@ async function getRemoteDocument(
    } else {
      const entries = link.getByRel("alternate");
      for (const [uri, params] of entries) {
        const altUri = new URL(uri, docUrl);
        if (
          "type" in params &&
          (params.type === "application/activity+json" ||
            params.type === "application/ld+json" ||
            params.type.startsWith("application/ld+json;")) &&
          new URL(uri).href !== docUrl.href
          altUri.href !== docUrl.href
        ) {
          logger.debug(
            "Found alternate document: {alternateUrl} from {url}",
            { alternateUrl: uri, url: documentUrl },
            { alternateUrl: altUri.href, url: documentUrl },
          );
          return await fetch(uri);
          return await fetch(altUri.href);
        }
      }
    }