Unverified Commit d6fcfc02 authored by Hong Minhee's avatar Hong Minhee
Browse files

Support `at://` pseudo-URI

parent debde3be
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@
    "apidoc",
    "bccs",
    "biomejs",
    "Bluesky",
    "Bridgy",
    "btos",
    "callouts",
    "cfworker",
+3 −0
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@ To be released.
    represented as `as:alsoKnownAs` property instead of `alsoKnownAs` property
    in compacted JSON-LD objects.

 -  Improved compatibility with Bridgy Fed for Bluesky where it puts
    an invalid URI with the format `at://...` in the `alsoKnownAs` property.


Version 1.0.3
-------------
+485 −97

File changed.

Preview size limit exceeded, changes collapsed.

+5 −1
Original line number Diff line number Diff line
@@ -369,7 +369,11 @@ export async function* generateDecoder(
      yield `
      if (typeof v === "object" && "@id" in v && !("@type" in v)
          && globalThis.Object.keys(v).length === 1) {
        ${variable}.push(new URL(v["@id"]));
        ${variable}.push(
          !URL.canParse(v["@id"]) && v["@id"].startsWith("at://")
            ? new URL("at://" + encodeURIComponent(v["@id"].substring(5)))
            : new URL(v["@id"])
        );
        continue;
      }
      `;
+22 −0
Original line number Diff line number Diff line
@@ -520,6 +520,28 @@ test("Person.fromJsonLd()", async () => {
    publicKey?.ownerId,
    new URL("https://todon.eu/users/hongminhee"),
  );

  const person2 = await Person.fromJsonLd({
    "@context": [
      "https://www.w3.org/ns/activitystreams",
      {
        alsoKnownAs: {
          "@id": "as:alsoKnownAs",
          "@type": "@id",
        },
      },
    ],
    "type": "Person",
    // cSpell: disable
    "alsoKnownAs": "at://did:plc:x7xdowahlhm5xulzqw4ehv6q",
    // cSpell: enable
  });
  assertEquals(
    person2.aliasId,
    // cSpell: disable
    new URL("at://did%3Aplc%3Ax7xdowahlhm5xulzqw4ehv6q"),
    // cSpell: enable
  );
});

test("Person.toJsonLd()", async () => {