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(cloud-function): redirect non-canonical URLs #11151

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

caugner
Copy link
Contributor

@caugner caugner commented May 17, 2024

Summary

(MP-1111)

Problem

We currently serve the same content independent of capitalization:

Solution

Fetch the metadata.json and match the URL (excluding search parameters) against the mdn_url in it.


How did you test this change?

  1. Ran npm ci && npm start in /cloud-function.
  2. Verified that http://localhost:5100/en-US/docs/web?foo=bar redirects to http://localhost:5100/en-US/docs/Web?foo=bar.

@caugner caugner requested a review from a team as a code owner May 17, 2024 23:07
@github-actions github-actions bot added redirects all things related to redirecting cloud-function labels May 17, 2024
Copy link
Contributor

@fiji-flo fiji-flo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a way that doesn't add another fetch please?

@caugner caugner marked this pull request as draft June 7, 2024 21:34
1. Build `sitemap.txt`, with all pages from all sitemaps.
2. Build `sitemap.json` for the Cloud Function, similar to the `redirects.json`.
3. Use middleware to redirect all URLs that match after normalization.
@caugner caugner marked this pull request as ready for review June 7, 2024 22:28
@caugner caugner requested a review from fiji-flo June 7, 2024 22:28
@caugner
Copy link
Contributor Author

caugner commented Jun 7, 2024

Can we use a way that doesn't add another fetch please?

Here's my second approach, utilizing a global sitemap.

@caugner caugner changed the title feat(cloud-function): redirect capitalization feat(cloud-function): redirect non-canonical URLs Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloud-function github-actions redirects all things related to redirecting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants