Puts a page's current path in the URL once the page knows it. A user, dump or playlist reached by a former name or slug, or by a name in another case, comes back from the API under its current one, from which the page builds its path; the server's OG middleware answers the same with a 301.

Functions

f
useCanonicalPath(canonical: string | null | undefined): void

Replaces the current path with canonical when they differ, keeping the query string, the hash and the history entry's state. It replaces the entry, so going back skips the old path. Nothing happens while canonical is null, as while the page loads. The profile, dump, dump editor and playlist pages call it.

Usage

import * as mod from "src/hooks/shared/useCanonicalPath.ts";