Handle domain name in share URL path

Skip domain-like segments (containing dots) when parsing the share path.
e.g., /share/slug/aol.com is treated as /share/slug
      /share/slug/aol.com/events is treated as /share/slug/events

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Mike Cao 2026-01-28 23:38:07 -08:00
parent c9e14f3bce
commit 4e8be724ac
2 changed files with 26 additions and 2 deletions

View file

@ -32,11 +32,23 @@ const ALL_SECTION_IDS = [
'attribution',
];
function getSharePath(pathname: string) {
const segments = pathname.split('/');
const firstSegment = segments[3];
// If first segment looks like a domain name, skip it
if (firstSegment?.includes('.')) {
return segments[4];
}
return firstSegment;
}
export function ShareProvider({ slug, children }: { slug: string; children: ReactNode }) {
const { share, isLoading, isFetching } = useShareTokenQuery(slug);
const router = useRouter();
const pathname = usePathname();
const path = pathname.split('/')[3];
const path = getSharePath(pathname);
const allowedSections = share?.parameters
? ALL_SECTION_IDS.filter(id => share.parameters[id] !== false)

View file

@ -39,11 +39,23 @@ const PAGE_COMPONENTS: Record<string, React.ComponentType<{ websiteId: string }>
attribution: AttributionPage,
};
function getSharePath(pathname: string) {
const segments = pathname.split('/');
const firstSegment = segments[3];
// If first segment looks like a domain name, skip it
if (firstSegment?.includes('.')) {
return segments[4];
}
return firstSegment;
}
export function SharePage() {
const share = useShare();
const { setTheme } = useTheme();
const pathname = usePathname();
const path = pathname.split('/')[3];
const path = getSharePath(pathname);
const { websiteId, parameters = {} } = share;
useEffect(() => {