Add wildcard prefix to Pages redirects for translated docs

What does this MR do and why?

Adds a wildcard prefix to URL paths when generating the _redirects file for GitLab Pages.

This will allow the same redirects we use for English to work for pages with language prefixes in their URLs.

For example, a redirect like this works for English:

/user/product_analytics/ /development/internal_analytics/product_analytics/ 301

But for localization, we also need a redirect like this, which will work for other languages, where the original URL is like /ja-JP/user/product_analytics/ (Japanese language prefix):

/*/user/product_analytics/ /:splat/development/internal_analytics/product_analytics/ 301

This MR also improves test coverage for the redirect script. The test should call the real BuildRedirects() method rather than mocking its logic separately.

Screenshots, screen recordings, or links to review app

Redirects file on the review app: https://docs.gitlab.com/review-mr-594/_redirects (all rules should show as "Valid")

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Configure a local GitLab Docs environment.
  2. Check out this branch.
  3. Generate a new redirects file: go run cmd/main.go build
  4. Review the file: cat static/_redirects

Expected behavior:

  • English redirects are created the same as before
  • Each redirect includes a wildcard-prefixed redirect, which will handle the redirect for non-English pages

Merge request acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sarah German

Merge request reports

Loading