Skip to content

fix: version switcher 404 on non versioned pages#2334

Merged
bjohansebas merged 1 commit into
expressjs:mainfrom
jonchurch:fix-version-switcher
May 24, 2026
Merged

fix: version switcher 404 on non versioned pages#2334
bjohansebas merged 1 commit into
expressjs:mainfrom
jonchurch:fix-version-switcher

Conversation

@jonchurch
Copy link
Copy Markdown
Member

@jonchurch jonchurch commented May 19, 2026

closes #2330

Problem

There were two different handlers for version switching, and the buggy one was handling the version switch.

In the "buggy" one, it assumed we were on a versioned page, which was not always the case. So when switching from the blog en/blog, it would update the URL to be /en/4x/blog and we'd 404

Fix

Drop the other dumber handler, wire up the SidebarVersionManager to listen to the correct event.

The SidebarVersionManager correctly implements the case where we are on a non versioned page and switch versions from the sidebar, it will drop us into the sidebar section we have open at the correct version. But it was listening for the wrong event, so never had a chance to trigger the correct logic.

The other handler was dumber and did not have that logic, but was the one handling the event.

@jonchurch jonchurch requested a review from a team as a code owner May 19, 2026 21:55
@netlify
Copy link
Copy Markdown

netlify Bot commented May 19, 2026

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 7d89cd8
🔍 Latest deploy log https://app.netlify.com/projects/expressjscom-preview/deploys/6a0cdc8f4b63c000083631e9
😎 Deploy Preview https://deploy-preview-2334--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 96 (🔴 down 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@jonchurch jonchurch force-pushed the fix-version-switcher branch from bbf9655 to 7d89cd8 Compare May 19, 2026 21:56
Comment on lines -133 to -144
getVersion(): string {
return this.currentVersion;
}

setVersion(version: string): void {
const versionSelects =
this.sidebar.querySelectorAll<HTMLSelectElement>('[data-version-select]');
versionSelects.forEach((select) => {
select.value = version;
});
this.handleVersionChange(version);
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are unused, so I removed them.

@bjohansebas bjohansebas merged commit 9009d40 into expressjs:main May 24, 2026
18 of 19 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.

Changing API version in menu redirects to 404 page when using non-versioned page

2 participants