diff --git a/website/package-lock.json b/website/package-lock.json index eb366402..d25ec27c 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -2472,9 +2472,9 @@ } }, "node_modules/basic-ftp": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.2.2.tgz", - "integrity": "sha512-1tDrzKsdCg70WGvbFss/ulVAxupNauGnOlgpyjKzeQxzyllBLS0CGLV7tjIXTK3ZQA9/FBEm9qyFFN1bciA6pw==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.0.tgz", + "integrity": "sha512-5K9eNNn7ywHPsYnFwjKgYH8Hf8B5emh7JKcPaVjjrMJFQQwGpwowEnZNEtHs7DfR7hCZsmaK3VA4HUK0YarT+w==", "dev": true, "license": "MIT", "engines": { diff --git a/website/src/utils/router.js b/website/src/utils/router.js index e2464e11..dd033ed4 100644 --- a/website/src/utils/router.js +++ b/website/src/utils/router.js @@ -136,7 +136,15 @@ export function initRouter() { * Handle route change */ function handleRoute() { - const path = getCurrentRoute() + let path = getCurrentRoute() + + // Normalize trailing slash: GitHub Pages 301-redirects /workflow to /workflow/ + // when workflow/index.html is served as a directory index. Without this, + // routes.get('/workflow/') misses the '/workflow' key and falls through to + // the home handler. + if (path.length > 1 && path.endsWith('/')) { + path = path.slice(0, -1) + } // Check for anchor route (/anchor/:id) if (path.startsWith('/anchor/')) { diff --git a/website/tests/e2e/website.spec.js b/website/tests/e2e/website.spec.js index fb750af6..d3a83676 100644 --- a/website/tests/e2e/website.spec.js +++ b/website/tests/e2e/website.spec.js @@ -277,15 +277,27 @@ test.describe('Routing - Documentation Pages', () => { await expect(anchorsLink).toHaveClass(/font-semibold/) }) - test.skip('should handle direct URL to About page', async ({ page }) => { - // Skip: direct URL routing requires 404.html fallback (only works on GitHub Pages) - await page.goto('/about') + test('should handle direct URL to About page', async ({ page }) => { + await page.goto('/Semantic-Anchors/about') // Wait for AsciiDoc content to load and check h1 in content area (not header) await page.waitForSelector('#doc-content h1', { timeout: 10000 }) await expect(page.locator('#doc-content h1')).toContainText(/About|What are/) }) + test('should render doc page when visited via trailing-slash URL', async ({ page }) => { + // GitHub Pages 301-redirects /workflow → /workflow/ when workflow/index.html + // is served as a directory index. The SPA must handle the trailing-slash + // form or it falls through to the home handler. + await page.goto('/Semantic-Anchors/workflow/') + + await page.waitForSelector('#doc-content h1', { timeout: 10000 }) + await expect(page.locator('#doc-content h1')).toContainText(/Workflow/i) + + // Card grid (home-only content) must not be rendered on top + await expect(page.locator('.anchor-card')).toHaveCount(0) + }) + test('should handle browser back button', async ({ page }) => { // Navigate to About via More dropdown await page.locator('#more-menu-toggle').click()