Unverified Commit 936004bd authored by Hong Minhee's avatar Hong Minhee
Browse files

Let Context.parseUri() take null as well

parent 5c6e1394
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ To be released.
     -  The first parameter of the `InboxListener` callback type became
        `InboxContext` (was `Context`).

 -  The `Context.parseUri()` method's parameter type became `URL | null`
    (was `URL`).

 -  `Context.sendActivity()` method now adds Object Integrity Proofs to
    the activity to be sent only once.  It had added Object Integrity Proofs
    to the activity for every recipient before.
+1 −1
Original line number Diff line number Diff line
{
  "devDependencies": {
    "@deno/kv": "^0.8.2",
    "@fedify/fedify": "^1.0.0-dev.388",
    "@fedify/fedify": "^1.0.0-dev.398",
    "@hono/node-server": "^1.12.2",
    "@js-temporal/polyfill": "^0.4.4",
    "@logtape/logtape": "^0.5.1",
+5 −5
Original line number Diff line number Diff line
@@ -12,8 +12,8 @@ importers:
        specifier: ^0.8.2
        version: 0.8.2
      '@fedify/fedify':
        specifier: ^1.0.0-dev.388
        version: 1.0.0-dev.388(web-streams-polyfill@3.3.3)
        specifier: ^1.0.0-dev.398
        version: 1.0.0-dev.398(web-streams-polyfill@3.3.3)
      '@hono/node-server':
        specifier: ^1.12.2
        version: 1.12.2(hono@4.6.1)
@@ -361,8 +361,8 @@ packages:
    resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==}
    engines: {node: '>=14'}

  '@fedify/fedify@1.0.0-dev.388':
    resolution: {integrity: sha512-/z+VC6ZlOYwkAvN6P5BRYQ4irHD1jMCCTa0HPJT66rJ8XhRu3MyZDOiULlsAz5NJza4rnmU/0ArQ3mDWCj1GDg==}
  '@fedify/fedify@1.0.0-dev.398':
    resolution: {integrity: sha512-3e2MDIIqZ0vv2UA6Wc/EjzdGvoKh+uaofMI0DEaN5szb4JLjjl1Y4WycJ3U60oOvHx6drZFKDCUc0DdcmW6jrw==}

  '@floating-ui/core@1.6.7':
    resolution: {integrity: sha512-yDzVT/Lm101nQ5TCVeK65LtdN7Tj4Qpr9RTXJ2vPFLqtLxwOrpoxAHAJI8J3yYWUc40J0BDBheaitK5SJmno2g==}
@@ -1911,7 +1911,7 @@ snapshots:

  '@fastify/busboy@2.1.1': {}

  '@fedify/fedify@1.0.0-dev.388(web-streams-polyfill@3.3.3)':
  '@fedify/fedify@1.0.0-dev.398(web-streams-polyfill@3.3.3)':
    dependencies:
      '@deno/shim-crypto': 0.3.1
      '@deno/shim-deno': 0.18.2
+3 −1
Original line number Diff line number Diff line
@@ -151,9 +151,11 @@ export interface Context<TContextData> {
  /**
   * Determines the type of the URI and extracts the associated data.
   * @param uri The URI to parse.
   * @returns The result of parsing the URI.  If `null` is given or
   *          the URI is not recognized, `null` is returned.
   * @since 0.9.0
   */
  parseUri(uri: URL): ParseUriResult | null;
  parseUri(uri: URL | null): ParseUriResult | null;

  /**
   * Gets the key pairs for an actor.
+10 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ test("Federation.createContext()", async (t) => {
    assertThrows(() => ctx.getFeaturedUri("handle"), RouterError);
    assertThrows(() => ctx.getFeaturedTagsUri("handle"), RouterError);
    assertEquals(ctx.parseUri(new URL("https://example.com/")), null);
    assertEquals(ctx.parseUri(null), null);
    assertEquals(await ctx.getActorKeyPairs("handle"), []);
    assertRejects(
      () => ctx.getDocumentLoader({ handle: "handle" }),
@@ -172,6 +173,7 @@ test("Federation.createContext()", async (t) => {
      ctx.parseUri(new URL("https://example.com/users/handle")),
      { type: "actor", handle: "handle" },
    );
    assertEquals(ctx.parseUri(null), null);
    assertEquals(
      await ctx.getActorKeyPairs("handle"),
      [
@@ -274,6 +276,7 @@ test("Federation.createContext()", async (t) => {
        values: { handle: "john", id: "123" },
      },
    );
    assertEquals(ctx.parseUri(null), null);

    federation.setInboxListeners("/users/{handle}/inbox", "/inbox");
    ctx = federation.createContext(new URL("https://example.com/"), 123);
@@ -290,6 +293,7 @@ test("Federation.createContext()", async (t) => {
      ctx.parseUri(new URL("https://example.com/users/handle/inbox")),
      { type: "inbox", handle: "handle" },
    );
    assertEquals(ctx.parseUri(null), null);

    federation.setOutboxDispatcher(
      "/users/{handle}/outbox",
@@ -304,6 +308,7 @@ test("Federation.createContext()", async (t) => {
      ctx.parseUri(new URL("https://example.com/users/handle/outbox")),
      { type: "outbox", handle: "handle" },
    );
    assertEquals(ctx.parseUri(null), null);

    federation.setFollowingDispatcher(
      "/users/{handle}/following",
@@ -318,6 +323,7 @@ test("Federation.createContext()", async (t) => {
      ctx.parseUri(new URL("https://example.com/users/handle/following")),
      { type: "following", handle: "handle" },
    );
    assertEquals(ctx.parseUri(null), null);

    federation.setFollowersDispatcher(
      "/users/{handle}/followers",
@@ -332,6 +338,7 @@ test("Federation.createContext()", async (t) => {
      ctx.parseUri(new URL("https://example.com/users/handle/followers")),
      { type: "followers", handle: "handle" },
    );
    assertEquals(ctx.parseUri(null), null);

    federation.setLikedDispatcher(
      "/users/{handle}/liked",
@@ -346,6 +353,7 @@ test("Federation.createContext()", async (t) => {
      ctx.parseUri(new URL("https://example.com/users/handle/liked")),
      { type: "liked", handle: "handle" },
    );
    assertEquals(ctx.parseUri(null), null);

    federation.setFeaturedDispatcher(
      "/users/{handle}/featured",
@@ -360,6 +368,7 @@ test("Federation.createContext()", async (t) => {
      ctx.parseUri(new URL("https://example.com/users/handle/featured")),
      { type: "featured", handle: "handle" },
    );
    assertEquals(ctx.parseUri(null), null);

    federation.setFeaturedTagsDispatcher(
      "/users/{handle}/tags",
@@ -374,6 +383,7 @@ test("Federation.createContext()", async (t) => {
      ctx.parseUri(new URL("https://example.com/users/handle/tags")),
      { type: "featuredTags", handle: "handle" },
    );
    assertEquals(ctx.parseUri(null), null);
  });

  await t.step("RequestContext", async () => {
Loading