v4: every request about a user, and the dump editor's path, come from one builder each — fourteen places wrote /api/users/<key>/… by hand, some encoding a handle (@alice%40music.example) and some not, a slug never; userApiUrl (src/utils/shared/urls.ts) now writes them all, by the user's id or by @ and the handle a page's path gives, each segment encoded. The editor's path was the dump's page's with /edit added in two places; dumpPath takes the view, as userPath and feedPath do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -102,9 +102,13 @@ export function userPath(
|
||||
: `${base}/${tab}`;
|
||||
}
|
||||
|
||||
/** Returns the path of a dump's page, `/@owner/dumps/<slug>`. */
|
||||
export function dumpPath(dump: OwnedItem): string {
|
||||
return `${userPath(dump.ownerUsername)}/dumps/${seg(dump.slug)}`;
|
||||
/**
|
||||
* Returns the path of a dump's page, `/@owner/dumps/<slug>`, or of its
|
||||
* editor, one segment more.
|
||||
*/
|
||||
export function dumpPath(dump: OwnedItem, view?: "edit"): string {
|
||||
const path = `${userPath(dump.ownerUsername)}/dumps/${seg(dump.slug)}`;
|
||||
return view ? `${path}/${view}` : path;
|
||||
}
|
||||
|
||||
/** Returns the path of a playlist's page, `/@owner/playlists/<slug>`. */
|
||||
|
||||
@@ -20,6 +20,10 @@ Deno.test("builders: one hierarchy, default views bare", () => {
|
||||
const item = { ownerUsername: "bob", slug: "never-gonna" };
|
||||
assertEquals(dumpPath(item), "/@bob/dumps/never-gonna");
|
||||
assertEquals(playlistPath(item), "/@bob/playlists/never-gonna");
|
||||
assertEquals(
|
||||
dumpPath({ ownerUsername: "bob", slug: "a-b" }, "edit"),
|
||||
"/@bob/dumps/a-b/edit",
|
||||
);
|
||||
assertEquals(feedPath(), "/");
|
||||
assertEquals(feedPath(undefined, "hot"), "/hot");
|
||||
assertEquals(feedPath("music"), "/music");
|
||||
|
||||
Reference in New Issue
Block a user