import { useLocation } from "react-router"; export function usePath() { // Decode special characters. Drop trailing slash. (Some clients add it, e.g. Playwright.) const path = decodeURIComponent(useLocation().pathname).replace(/[/]$/, ""); return path; }