Skip to content

fix: support /god-mode route without trailing slash (#9068)#9070

Open
rishipandey2 wants to merge 3 commits into
makeplane:previewfrom
rishipandey2:fix-god-mode-trailing-slash
Open

fix: support /god-mode route without trailing slash (#9068)#9070
rishipandey2 wants to merge 3 commits into
makeplane:previewfrom
rishipandey2:fix-god-mode-trailing-slash

Conversation

@rishipandey2
Copy link
Copy Markdown

@rishipandey2 rishipandey2 commented May 14, 2026

Closes #9068

Summary

Fixes an issue where accessing /god-mode without a trailing slash caused the admin app to render a blank/loading page.

Root Cause

The admin router basename and Vite base path were configured with a trailing slash (/god-mode/), causing React Router to fail matching requests to /god-mode.

Changes

  • Normalized the admin base path configuration to consistently remove trailing slashes for:

    • React Router basename
    • Vite base config

Testing

Verified that:

  • /god-mode renders correctly
  • /god-mode/ renders correctly
  • both routes behave consistently without router basename errors

Summary by CodeRabbit

  • Refactor
    • Improved base-path normalization for admin build and routing to produce more consistent URLs and avoid edge-case path issues.
  • Bug Fixes
    • Tightened email validation and simplified comment-empty detection for more reliable input handling.
  • Style / Minor Improvements
    • Made string shuffling non-mutating to improve safety.
  • New Features
    • Added a utility for normalizing base paths across the app.

Review Change Stack

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 14, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0d579e3-62d0-4620-9332-91f19dec6cff

📥 Commits

Reviewing files that changed from the base of the PR and between 5a40abf and 3de5608.

📒 Files selected for processing (1)
  • packages/utils/src/string.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/utils/src/string.ts

📝 Walkthrough

Walkthrough

The admin app now uses a new normalizeBasePath utility; React Router and Vite configs derive basePath from VITE_ADMIN_BASE_PATH via this normalization (trim, collapse duplicate slashes, remove trailing slash except root, ensure leading slash).

Changes

Admin base path normalization

Layer / File(s) Summary
Add normalizeBasePath & string util tweaks
packages/utils/src/string.ts
Adds exported normalizeBasePath(rawBasePath) and small non-functional updates: createSimilarString uses toSorted, checkEmailValidity regex literal adjusted, and isCommentEmpty simplified.
React Router base path normalization
apps/admin/react-router.config.ts
Router basename now computes basePath with normalizeBasePath(process.env.VITE_ADMIN_BASE_PATH ?? "") and updates the @plane/utils import.
Vite base path normalization
apps/admin/vite.config.ts
Vite base now uses normalizeBasePath(process.env.VITE_ADMIN_BASE_PATH ?? ""); joinUrlPath import replaced with normalizeBasePath.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I trimmed the slashes, hopped through each path,
I made the base tidy, avoided the wrath.
Whether /god-mode or /god-mode/ you send,
The router now matches from start to the end. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main change: fixing /god-mode route support without trailing slash, directly addressing the core issue being resolved.
Description check ✅ Passed The PR description adequately covers the root cause, changes made, and testing verification, though it omits some optional template sections like Type of Change and Screenshots.
Linked Issues check ✅ Passed The PR successfully implements the solution to issue #9068 by normalizing base paths in React Router and Vite config to remove trailing slashes, allowing both /god-mode and /god-mode/ to work correctly.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the trailing slash issue: normalizeBasePath utility is added, and React Router/Vite configs are updated to use it consistently.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
apps/admin/vite.config.ts (1)

17-20: ⚡ Quick win

Avoid normalization drift between Vite and React Router configs.

This block duplicates the same base-path logic from apps/admin/react-router.config.ts. Extracting a shared normalizeBasePath helper keeps both layers in lockstep and prevents regressions from future one-sided edits.

🤖 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/admin/vite.config.ts` around lines 17 - 20, Extract the base-path
normalization into a shared function named normalizeBasePath that implements the
existing logic (treat raw "" or "/" as "/", otherwise strip trailing slashes
with raw.replace(/\/+$/, "")); replace the inline logic in
apps/admin/vite.config.ts (the const rawBasePath / basePath block) and in
apps/admin/react-router.config.ts to call normalizeBasePath(rawBasePath) so both
configs import and use the same helper and stay in sync.
apps/admin/react-router.config.ts (1)

3-5: ⚡ Quick win

Harden base path normalization for slash-only and no-leading-slash inputs.

On Line 5, values like "////" normalize to "", and "god-mode/" normalizes to "god-mode" (no leading slash). Normalizing these to an absolute path shape avoids fragile env-dependent behavior.

Proposed change
-const rawBasePath = process.env.VITE_ADMIN_BASE_PATH ?? "";
-
-const basePath = rawBasePath === "/" || rawBasePath === "" ? "/" : rawBasePath.replace(/\/+$/, "");
+const normalizeBasePath = (rawBasePath: string): string => {
+  const trimmed = rawBasePath.trim();
+  if (trimmed === "" || /^\/+$/.test(trimmed)) return "/";
+  const withoutTrailingSlashes = trimmed.replace(/\/+$/, "");
+  return withoutTrailingSlashes.startsWith("/") ? withoutTrailingSlashes : `/${withoutTrailingSlashes}`;
+};
+
+const basePath = normalizeBasePath(process.env.VITE_ADMIN_BASE_PATH ?? "");
🤖 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/admin/react-router.config.ts` around lines 3 - 5, The basePath
normalization is fragile for inputs like "////" or "god-mode/"; update the logic
around rawBasePath/basePath to first collapse repeated slashes, then strip
trailing slashes (but preserve a single leading slash), and if the resulting
path is empty or only slashes, set basePath to "/". Concretely: normalize
rawBasePath by replacing multiple consecutive slashes with one, remove any
trailing slash(es) except the leading one, and ensure the final basePath always
starts with a "/" (falling back to "/" for empty results).
🤖 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/admin/react-router.config.ts`:
- Around line 3-5: The basePath normalization is fragile for inputs like "////"
or "god-mode/"; update the logic around rawBasePath/basePath to first collapse
repeated slashes, then strip trailing slashes (but preserve a single leading
slash), and if the resulting path is empty or only slashes, set basePath to "/".
Concretely: normalize rawBasePath by replacing multiple consecutive slashes with
one, remove any trailing slash(es) except the leading one, and ensure the final
basePath always starts with a "/" (falling back to "/" for empty results).

In `@apps/admin/vite.config.ts`:
- Around line 17-20: Extract the base-path normalization into a shared function
named normalizeBasePath that implements the existing logic (treat raw "" or "/"
as "/", otherwise strip trailing slashes with raw.replace(/\/+$/, "")); replace
the inline logic in apps/admin/vite.config.ts (the const rawBasePath / basePath
block) and in apps/admin/react-router.config.ts to call
normalizeBasePath(rawBasePath) so both configs import and use the same helper
and stay in sync.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a334fcb5-3736-4caa-a0c8-4dbd967111e2

📥 Commits

Reviewing files that changed from the base of the PR and between 4225bc5 and 8388e8c.

📒 Files selected for processing (2)
  • apps/admin/react-router.config.ts
  • apps/admin/vite.config.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@packages/utils/src/string.ts`:
- Around line 435-451: Add a JSDoc block above the exported function
normalizeBasePath describing its purpose, include `@description` that explains it
normalizes a raw base path to a canonical URL path (empty or slash-only => "/",
collapse multiple slashes, remove trailing slashes except root, ensure leading
slash), add `@param` {string} rawBasePath explanation, add `@returns` {string}
describing the normalized path, and include an `@example` showing typical inputs
and outputs (e.g. "", "/", "///api//v1/", "api/v1" ->
"/","/","/api/v1","/api/v1"). Ensure the JSDoc follows the same style and tags
used by other exported functions in this file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6e8a8a27-b60e-4c55-94aa-e886029c81d0

📥 Commits

Reviewing files that changed from the base of the PR and between 8388e8c and 5a40abf.

📒 Files selected for processing (3)
  • apps/admin/react-router.config.ts
  • apps/admin/vite.config.ts
  • packages/utils/src/string.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/admin/react-router.config.ts

Comment thread packages/utils/src/string.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/god-mode without trailing slash renders a blank/loading page

2 participants