fix: correct Memos links and author identities
This commit is contained in:
+10
-4
@@ -1,15 +1,21 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { postAuthorLabel } from "../lib/display";
|
||||
import { memoUrl } from "../lib/memos";
|
||||
|
||||
test("formats Memos authors as name at source hostname", () => {
|
||||
assert.equal(postAuthorLabel({ origin: "memos", username: "hub-user", name: "codex", remote_display_name: "codex", source_base_url: "https://memos.fishking.studio/path" }), "@codex@memos.fishking.studio");
|
||||
test("formats Memos authors as remote user at source hostname", () => {
|
||||
assert.equal(postAuthorLabel({ origin: "memos", username: "hub-user", name: "唐宋打油", remote_user: "users/tangsong", remote_display_name: "唐宋打油", source_base_url: "https://memos.fishking.studio/path" }), "@tangsong@memos.fishking.studio");
|
||||
});
|
||||
|
||||
test("formats Hub posts linked to Memos with the same source identity", () => {
|
||||
assert.equal(postAuthorLabel({ origin: "hub", username: "codex", name: "codex", remote_display_name: "codex", source_base_url: "https://memos.fishking.studio" }), "@codex@memos.fishking.studio");
|
||||
assert.equal(postAuthorLabel({ origin: "hub", username: "codex", name: "唐宋打油", remote_user: "users/tangsong", remote_display_name: "唐宋打油", source_base_url: "https://memos.fishking.studio" }), "@tangsong@memos.fishking.studio");
|
||||
});
|
||||
|
||||
test("keeps the existing label for non-Memos posts", () => {
|
||||
assert.equal(postAuthorLabel({ origin: "hub", username: "codex", name: "Hub", source_base_url: null }), "@Hub · Hub");
|
||||
assert.equal(postAuthorLabel({ origin: "hub", username: "codex", name: "Hub", source_base_url: null }), "@codex");
|
||||
});
|
||||
|
||||
test("uses current Memos UID links while preserving legacy numeric links", () => {
|
||||
assert.equal(memoUrl("https://memos.example.com/", "memos/VA54SvJG7yBparf3SiH3Ey"), "https://memos.example.com/memos/VA54SvJG7yBparf3SiH3Ey");
|
||||
assert.equal(memoUrl("https://memos.example.com", "memos/15"), "https://memos.example.com/m/15");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user