mirror of
https://github.com/BradNut/umami
synced 2025-09-08 17:40:29 +00:00
17 lines
412 B
TypeScript
17 lines
412 B
TypeScript
import { usePathname } from 'next/navigation';
|
|
|
|
export function useTeamUrl(): {
|
|
teamId?: string;
|
|
renderTeamUrl: (url: string) => string;
|
|
} {
|
|
const pathname = usePathname();
|
|
const [, teamId] = pathname.match(/^\/teams\/([a-f0-9-]+)/) || [];
|
|
|
|
function renderTeamUrl(url: string) {
|
|
return teamId ? `/teams/${teamId}${url}` : url;
|
|
}
|
|
|
|
return { teamId, renderTeamUrl };
|
|
}
|
|
|
|
export default useTeamUrl;
|