Validate redirects instead of rewriting them#219
Merged
Conversation
|
Amplify deployment status
|
Contributor
Author
|
Need to merge these content PRS before we can merge this one: |
In order to migrate the legacy custom site to Docusaurus, we added logic to the Docusaurus config to convert redirects to use the Docusaurus format. The logic included some steps to rewrite redirect sources and desinations. This change adjusts the logic to validate redirects instead and throw errors on malformed redirects. This way, it is easier to troubleshoot issues with redirects, since the redirects that a documentation author would see are the same ones that Docusaurus processes. As part of this, this change adds a rule to require a leading slash in redirect paths. When validating redirects, Docusaurus ignores destinations that do not begin with a slash, causing unexpected issues for custom logic in the docs engine that expects redirect paths to begin with slashes. For context, see the following file in facebook/docusaurus#9171: packages/docusaurus-plugin-client-redirects/src/collectRedirects.ts
2111884 to
6dea021
Compare
avatus
approved these changes
May 22, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In order to migrate the legacy custom site to Docusaurus, we added logic to the Docusaurus config to convert redirects to use the Docusaurus format. The logic included some steps to rewrite redirect sources and desinations.
This change adjusts the logic to validate redirects instead and throw errors on malformed redirects. This way, it is easier to troubleshoot issues with redirects, since the redirects that a documentation author would see are the same ones that Docusaurus processes.
As part of this, this change adds a rule to require a leading slash in redirect paths. When validating redirects, Docusaurus ignores destinations that do not begin with a slash, causing unexpected issues for custom logic in the docs engine that expects redirect paths to begin with slashes.
For context, see the following file in facebook/docusaurus#9171:
packages/docusaurus-plugin-client-redirects/src/collectRedirects.ts