Skip to content

Validate redirects instead of rewriting them#219

Merged
ptgott merged 1 commit intomainfrom
paul.gottschling/2025-05-15-redir-fix
May 22, 2025
Merged

Validate redirects instead of rewriting them#219
ptgott merged 1 commit intomainfrom
paul.gottschling/2025-05-15-redir-fix

Conversation

@ptgott
Copy link
Contributor

@ptgott ptgott commented May 15, 2025

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

@github-actions
Copy link

github-actions bot commented May 15, 2025

Amplify deployment status

Branch Commit Job ID Status Preview Updated (UTC)
paul.gottschling/2025-05-15-redir-fix 6dea021 6 ✅SUCCEED paul-gottschling-2025-05-15-redir-fix 2025-05-22 14:16:25

@ptgott
Copy link
Contributor Author

ptgott commented May 15, 2025

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
@ptgott ptgott force-pushed the paul.gottschling/2025-05-15-redir-fix branch from 2111884 to 6dea021 Compare May 22, 2025 14:02
@ptgott ptgott temporarily deployed to docs-amplify May 22, 2025 14:02 — with GitHub Actions Inactive
@ptgott ptgott requested a review from avatus May 22, 2025 15:09
@ptgott ptgott added this pull request to the merge queue May 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks May 22, 2025
@ptgott ptgott added this pull request to the merge queue May 22, 2025
Merged via the queue into main with commit 3a302a4 May 22, 2025
6 checks passed
@ptgott ptgott deleted the paul.gottschling/2025-05-15-redir-fix branch May 22, 2025 19:18
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.

2 participants