-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eac5fe7
fix(core): normalize /path.html to /path to prevent 404
Josh-Cena 76c2f2c
test no trailing slash
Josh-Cena 49a9fe2
dogfood?
Josh-Cena 9157cd5
Merge branch 'main' into jc/fix-normalize-location
Josh-Cena 5134e87
revert last change
Josh-Cena 77513e1
does this fix
Josh-Cena 0cf606a
ignore
Josh-Cena 63447e0
add test
Josh-Cena 67fa969
fix
Josh-Cena 91e0fdb
properly fix
Josh-Cena d4c982e
fix again
Josh-Cena 12eeedb
revert trailing slash change
Josh-Cena 2b82e53
optimize: use map instead of object
Josh-Cena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/docusaurus/src/client/__tests__/__mocks__/@generated/routes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
export default [ | ||
{ | ||
path: '/page.html', | ||
exact: true, | ||
component: '', | ||
}, | ||
{ | ||
path: '/docs', | ||
exact: false, | ||
component: '', | ||
routes: [ | ||
{ | ||
path: '/docs/installation', | ||
exact: true, | ||
component: '', | ||
}, | ||
], | ||
}, | ||
{ | ||
path: '*', | ||
component: '', | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
--- | ||
slug: dummy.html | ||
--- | ||
|
||
# Just a dummy page |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also handle
matchRoutes(routes, location.pathname + ".html");
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't do that for now, because it makes less sense.
/docs/installation.html
is a physical file that exists and can be served, so using this as a location makes sense. If the route is/docs/installation
, we should try to normalize/docs/installation.html
to that.However, if both the route and the physical file is
/docs/installation.html
, then/docs/installation
doesn't really make sense—it's nowhere to be found. Moreover, I'm worried that this would lead to more edge cases, especially around trailing slash andindex.html
.