Skip to content

fix: SPA router ignores trailing slash, breaking direct URL visits (#441)#442

Merged
rdmueller merged 2 commits into
LLM-Coding:mainfrom
raifdmueller:fix/router-trailing-slash
Apr 20, 2026
Merged

fix: SPA router ignores trailing slash, breaking direct URL visits (#441)#442
rdmueller merged 2 commits into
LLM-Coding:mainfrom
raifdmueller:fix/router-trailing-slash

Conversation

@raifdmueller
Copy link
Copy Markdown
Contributor

@raifdmueller raifdmueller commented Apr 20, 2026

Closes #441

Problem

Direct visits to clean routes (e.g. https://llm-coding.github.io/Semantic-Anchors/workflow) landed on the home page instead of the target page. In-app navigation worked; only direct URL entry broke.

Root cause

GitHub Pages 301-redirects /workflow/workflow/ when workflow/index.html is served as a directory index. After the redirect, window.location.pathname ends in a trailing slash. The router's routes.get('/workflow/') lookup missed the /workflow key and fell through to the home-page fallback, which wiped out the pre-rendered doc content.

Affected routes: /workflow, /brownfield, /about, /changelog, /contributing, /agentskill, /rejected-proposals, /all-anchors, /evaluations.

Fix

Normalize the trailing slash in handleRoute() before looking up the handler. Root path / remains unchanged.

Tests (Red/Green TDD)

  • Added should render doc page when visited via trailing-slash URL — goes to /Semantic-Anchors/workflow/ and asserts workflow content (not cards) renders.
  • Un-skipped should handle direct URL to About page — the stale skip comment referenced a 404.html fallback that's been superseded by per-route pre-rendering.

Verified Red on base branch (test fails without the router fix), Green after the change.

Test plan

  • New E2E test reproduces the bug on base
  • All 35 E2E tests pass after fix
  • All 89 unit tests still pass
  • CI green

Summary by CodeRabbit

  • Bug Fixes

    • Der Router normalisiert jetzt automatisch URL-Pfade mit abschließendem Schrägstrich. Pfade wie /workflow/ werden nun konsistent mit ihrer Entsprechung ohne Schrägstrich (/workflow) aufgelöst, was die Zuverlässigkeit der Routenauflösung verbessert.
  • Tests

    • Neue End-to-End-Tests zur Validierung der korrekten Routenauflösung und Inhaltsdarstellung bei URLs mit und ohne Trailing-Slash-Format.

GitHub Pages 301-redirects /workflow to /workflow/ when
workflow/index.html is served as a directory index. The SPA
router looked up the trailing-slash form in the route map and
missed the '/workflow' key, falling through to the home handler
and overwriting the pre-rendered doc content.

Normalize trailing slashes in handleRoute() before lookup.

Also un-skip the direct-URL test (pre-rendering removed the need
for a 404.html fallback) and add a regression test for the
trailing-slash case.

Closes LLM-Coding#441
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • website/package-lock.json is excluded by !**/package-lock.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: b634c63a-c468-4525-9b29-c474a3598fb3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Der Router normalisiert nun Pfade mit nachgestelltem Schrägstrich in der handleRoute-Funktion. Pfade länger als 1 Zeichen, die mit / enden, werden ohne den Schrägstrich gesucht. Dies behebt das Problem, dass direkte URLs zu bereinigten Routen (z. B. /workflow/) die Startseite statt der Zielseite anzeigten. Die E2E-Tests wurden entsprechend aktualisiert und ergänzt.

Changes

Cohort / File(s) Summary
Router-Normalisierung
website/src/utils/router.js
Implementiert Trailing-Slash-Normalisierung in handleRoute: Pfade mit Länge > 1, die auf / enden, werden bereinigt, bevor die Route-Nachschau erfolgt.
E2E-Tests
website/tests/e2e/website.spec.js
Reaktiviert Test für direkte URLs zur About-Seite und fügt neuen Test für Trailing-Slash-URLs hinzu (z. B. /Semantic-Anchors/workflow/), um korrektes Rendering des Zielinhalts zu prüfen.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • PR #385: Modifiziert die gleiche handleRoute-Funktion in website/src/utils/router.js — eine Änderung normalisiert Trailing-Slashes für Route-Lookups, die andere setzt per-Route-Dokumenttitel.
  • PR #198: Die Trailing-Slash-Normalisierung in handleRoute beeinflusst die Reihenfolge der Route-Nachschau vor der in PR #198 hinzugefügten Anchor-Route-Logik (routeBeforeModal/getRouteBeforeModal).
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Der Titel beschreibt klar die Hauptänderung: Der SPA-Router ignoriert nachfolgende Schrägstriche und verursacht Probleme bei direkten URL-Besuchen.
Linked Issues check ✅ Passed Die Implementierung erfüllt alle Anforderungen aus #441: Normalisierung von Schrägstrichen vor Route-Lookup, Erhaltung des Root-Pfads und E2E-Regressionstests.
Out of Scope Changes check ✅ Passed Alle Änderungen sind direkt auf die Behebung des Trailing-Slash-Fehlers und die entsprechenden Tests ausgerichtet; keine zusätzlichen Änderungen vorhanden.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

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

@rdmueller rdmueller merged commit 234ba58 into LLM-Coding:main Apr 20, 2026
7 checks passed
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.

Bug: direct URL /workflow (and other clean routes) lands on home instead of target page

2 participants