Files
5chan/src/lib/utils/view-utils.ts
T

15 lines
550 B
TypeScript
Raw Normal View History

2024-04-03 22:52:27 +02:00
export type ParamsType = {
commentCid?: string;
subplebbitAddress?: string;
};
export const isHomeView = (pathname: string): boolean => {
return pathname === '/';
};
2024-04-03 22:52:27 +02:00
export const isPostPageView = (pathname: string, params: ParamsType): boolean => {
// some subs might use emojis in their address, so we need to decode the pathname
const decodedPathname = decodeURIComponent(pathname);
return params.subplebbitAddress && params.commentCid ? decodedPathname.startsWith(`/p/${params.subplebbitAddress}/c/${params.commentCid}`) : false;
};