v4: a handle with this instance's own host names the local user — another instance writes bob from here as bob@gerbeur.example, so a mention or a link copied from there named no one here: /@bob@gerbeur.example was a 404, and the mention notified nobody. localHandle (shared/validation.ts) drops this instance's host, its API's or its pages', from a handle; resolveUsername reads names by it, so the page, the API and the Open Graph 301 reach bob at /@bob, and so do the mention notifications and the chat's highlight and chime.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
||||
isFederationEvent,
|
||||
parseInstance,
|
||||
} from "../federation.ts";
|
||||
import { HANDLE_RE, splitHandle } from "../validation.ts";
|
||||
import { HANDLE_RE, localHandle, splitHandle } from "../validation.ts";
|
||||
|
||||
Deno.test("parseInstance: a host or a URL names an instance's origin", () => {
|
||||
assertEquals(parseInstance("music.example"), "https://music.example");
|
||||
@@ -21,6 +21,13 @@ Deno.test("parseInstance: a host or a URL names an instance's origin", () => {
|
||||
assertEquals(instanceHost("http://localhost:8001"), "localhost:8001");
|
||||
});
|
||||
|
||||
Deno.test("handles: this instance's host is dropped, another's kept", () => {
|
||||
const self = (host: string) => host === "gerbeur.example";
|
||||
assertEquals(localHandle("bob@gerbeur.example", self), "bob");
|
||||
assertEquals(localHandle("bob@music.example", self), "bob@music.example");
|
||||
assertEquals(localHandle("bob", self), "bob");
|
||||
});
|
||||
|
||||
Deno.test("handles: a name, and a host for a user from another instance", () => {
|
||||
assertEquals(splitHandle("bob"), { name: "bob" });
|
||||
assertEquals(splitHandle("alice@music.example"), {
|
||||
|
||||
Reference in New Issue
Block a user