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

feat(client-redirects-plugin): support fully qualified urls and querystring/hash in destination/to url #9171

Merged
merged 3 commits into from
Jul 21, 2023

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Jul 21, 2023

Motivation

Fix #6845

The client redirect plugins should allow redirecting to:

  • fully resolved URIs
  • URLs with querystring and/or hash (fully resolved / absolute / relative)

The validation has been related to any string, because if we support full/absolute/relative almost all strings are valid candidates, and creating a robust validator for that is quite hard.

Historically the redirects forwarded the ?search#anchor from the redirect source. Now if the destination/target URL has a qs/hash, we don't do this forwarding anymore and consider the destination URL provided by the user is in its final form. We could improve that logic later if needed but that seems good enough for now.

Note: I'm not 100% sure this is perfectly retro-compatible, some difficult-to-detect subtle behavior could have changed a bit, so we won't backport this PR and keep it for Docusaurus v3.

Test Plan

Unit tests + dogfood

Test links

Local redirects

Fully qualified URL redirects:

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 21, 2023
@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Jul 21, 2023
@netlify
Copy link

netlify bot commented Jul 21, 2023

[V2]

Name Link
🔨 Latest commit 1a79e0a
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/64bac3249be63b0008d4c588
😎 Deploy Preview https://deploy-preview-9171--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@github-actions
Copy link

github-actions bot commented Jul 21, 2023

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟢 92 🟢 97 🟢 92 🟢 100 🟠 89 Report
/docs/installation 🟠 76 🟢 100 🟢 92 🟢 100 🟠 89 Report

@slorber slorber changed the title feat(client-redirects-plugin): support feat(client-redirects-plugin): support fully qualified urls and querystring/hash in destination/to url Jul 21, 2023
@slorber slorber added pr: new feature This PR adds a new API or behavior. and removed pr: bug fix This PR fixes a bug in a past release. labels Jul 21, 2023
@slorber slorber merged commit 09ea3bc into main Jul 21, 2023
30 of 31 checks passed
@slorber slorber deleted the slorber/relax-redirects-to-validation branch July 21, 2023 17:54
@github-actions
Copy link

Size Change: +277 B (0%)

Total Size: 1.1 MB

Filename Size Change
website/build/assets/js/main.********.js 829 kB +277 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 117 kB
website/build/assets/css/styles.********.css 113 kB
website/build/index.html 41 kB

compressed-size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugin-client-redirects should allow fully resolved URIs
2 participants