Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): prevent 404 when accessing /page.html #7184

Merged
merged 13 commits into from
Apr 22, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('normalizeLocation', () => {
hash: '#bar',
}),
).toEqual({
pathname: '/docs/introduction/foo.html',
pathname: '/docs/introduction/foo',
search: '',
hash: '#bar',
});
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/client/normalizeLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function normalizeLocation<T extends Location>(location: T): T {
}

const pathname =
location.pathname.trim().replace(/\/index\.html$/, '') || '/';
location.pathname.trim().replace(/(?:\/index)?\.html$/, '') || '/';

pathnames[location.pathname] = pathname;

Expand Down
2 changes: 1 addition & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const config = {
// Dogfood both settings:
// - force trailing slashes for deploy previews
// - avoid trailing slashes in prod
trailingSlash: isDeployPreview,
trailingSlash: false,
Josh-Cena marked this conversation as resolved.
Show resolved Hide resolved
stylesheets: [
{
href: '/katex/katex.min.css',
Expand Down