Skip to content

fix: improve booking page detection and satisfy explicit type lint#29799

Open
Gunwant35 wants to merge 2 commits into
calcom:mainfrom
Gunwant35:gunwant-Bug/fix-booking-page-detection
Open

fix: improve booking page detection and satisfy explicit type lint#29799
Gunwant35 wants to merge 2 commits into
calcom:mainfrom
Gunwant35:gunwant-Bug/fix-booking-page-detection

Conversation

@Gunwant35

Copy link
Copy Markdown

What does this PR do?

  • fix useIsBookingPage to detect dynamic public booking pages like /rick and /john+jane
  • preserve known booking prefixes and exclude reserved root paths
  • add explicit Set<string> type annotation for reservedRootPaths
  • add regression coverage for booking route detection

Note: Cal.diy is a community-maintained open-source project. Contributions here do NOT flow to Cal.com's production service. -->

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

- fix `useIsBookingPage` to detect dynamic public booking pages like `/rick` and `/john+jane`
- preserve known booking prefixes and exclude reserved root paths
- add explicit `Set<string>` type annotation for `reservedRootPaths`
- add regression coverage for booking route detection
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @Gunwant35! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added the 🐛 bug Something isn't working label Jul 18, 2026
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Refactors useIsBookingPage to delegate route classification to the exported isBookingPagePath helper. The helper normalizes paths, checks query parameters, matches booking prefixes and list suffixes, and rejects reserved root paths. A Vitest suite covers dynamic booking paths, reserved routes, known prefixes, booking-list exclusions, and query-parameter cases.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: improved booking page detection and the explicit type lint fix.
Description check ✅ Passed The description is directly related to the code changes and mentions the booking detection fix, lint annotation, and tests.
Linked Issues check ✅ Passed The PR addresses #29798 by detecting dynamic root booking routes, honoring reserved roots, and fixing the explicit type lint issue.
Out of Scope Changes check ✅ Passed The changes stay focused on booking page detection and regression tests, with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
apps/web/lib/hooks/useIsBookingPage.ts (1)

51-55: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify redundant boolean logic.

Because isUserBookingTypePage requires isUserBookingPage to be true, the condition isUserBookingPage || isUserBookingTypePage is logically equivalent to just isUserBookingPage. You can safely simplify this block.

♻️ Proposed refactor
-  const isUserBookingPage = Boolean(searchParams?.get("user"));
-  const isUserBookingTypePage = isUserBookingPage && Boolean(searchParams?.get("type"));
-  if (isUserBookingPage || isUserBookingTypePage) {
+  if (searchParams?.get("user")) {
     return true;
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/lib/hooks/useIsBookingPage.ts` around lines 51 - 55, In the
booking-page detection logic, simplify the condition using isUserBookingPage
because isUserBookingTypePage already depends on it; remove the redundant OR
branch while preserving the existing true return behavior.
apps/web/lib/__tests__/useIsBookingPage.test.ts (1)

46-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove duplicate test assertion.

These two assertions are completely identical. You can remove the duplicate line.

♻️ Proposed refactor
     expect(isBookingPagePath("/some/page", searchParams)).toBe(true);
-    expect(isBookingPagePath("/some/page", searchParams)).toBe(true);
   });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/lib/__tests__/useIsBookingPage.test.ts` around lines 46 - 48, Remove
the duplicate identical isBookingPagePath assertion in the affected test case,
keeping one assertion for the expected true result.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/web/lib/__tests__/useIsBookingPage.test.ts`:
- Around line 46-48: Remove the duplicate identical isBookingPagePath assertion
in the affected test case, keeping one assertion for the expected true result.

In `@apps/web/lib/hooks/useIsBookingPage.ts`:
- Around line 51-55: In the booking-page detection logic, simplify the condition
using isUserBookingPage because isUserBookingTypePage already depends on it;
remove the redundant OR branch while preserving the existing true return
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f1573a72-dfc5-4c69-9c1e-33990e3e9bfb

📥 Commits

Reviewing files that changed from the base of the PR and between f004349 and a846ecd.

📒 Files selected for processing (2)
  • apps/web/lib/__tests__/useIsBookingPage.test.ts
  • apps/web/lib/hooks/useIsBookingPage.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Improve booking page detection and satisfy explicit type lint

1 participant